我有一个选择所有/取消全选复选框的问题
代码如下:
<input type="checkbox" value="" onclick="checkedAll();" name="checkall" id="checkall"/>
function checkedAll() {
$('.all span').click(function () {
if(document.getElementById("checkall").checked == true)
{
$('#uniform-undefined span').addClass('checked');
}
else
{
$('#uniform-undefined span').removeClass('checked');
}
});
$.uniform.update();
}
当我选中复选框(所有复选框都为真)时,jQuery会添加一个带有class="checked"
的标签
spanTag.addClass(options.checkedClass);
没有任何复选框被选中。
<li><label><div id="uniform-undefined" class="checker">">
<span class="checked"><input type="checkbox" value="F2" style="opacity: 0;"></span>
</div><b>1 </b>
</label></li>
<li><label><div id="uniform-undefined" class="checker">
<span class="checked"><input type="checkbox" value="F2" style="opacity: 0;"></span>
</div><b>2 </b>
</label></li>
<li><label><div id="uniform-undefined" class="checker">
<span class="checked"><input type="checkbox" value="F3" style="opacity: 0;"></span>
</div><b>3 </b>
</label></li>
">
,而且你最后一组中的style=opacity: 0;"
缺少了一个"
。只想确认问题不是由于奇怪的 HTML 导致的。 - Nope$('input[type=checkbox]').attr('checked', true)
; - MCL