我有一个带有复选框的视图,动态生成的,以及一个用于检查/取消所有复选框的按钮。我尝试下面的代码,但是,复选框未选中 ob 按钮单击事件。请帮忙。谢谢你。
用复选框查看:
<button id="selectinvert" name="selectinvert" class="clear-selection ui-btn-hidden" aria-disabled="false" > Select / Deselect All</button>
@for (int i = 0; i < @Model.workDaysList.Count; i++)
{
<div class="framed">
<div data-role="collapsible" data-collapsed="true" class="ui-btn-inner ui-corner-top ui-corner-bottom">
<h3>
<div class="ui-checkbox" id="checkbox">
<input type="checkbox" id="@Model.workDaysList[i][0]" />
<span class="ui-btn-text">
<label for="@Model.workDaysList[i][0]" data-theme="c">
@Model.workDaysList[i][1].Substring(6, 2)/@Model.workDaysList[i][1].Substring(4, 2)/@Model.workDaysList[i][1].Substring(0, 4)
</label>
</span>
</div>
</h3>
@Model.detailDaysList[i][0] / @Model.detailDaysList[i][1]
<br />
@Model.detailDaysList[i][2] / @Model.detailDaysList[i][3]
<br />
@Model.detailDaysList[i][4] h
</div>
</div>
</div>
}
jQuery代码:
<script type="text/javascript">
$(document).ready(function () {
$("#selectinvert").click(function () {
$("INPUT[type='checkbox']").each(function () {
if (this.checked == false) {
this.checked = true;
} else {
this.checked = false;
}
});
});
});
</script>