我有代码工作,但是当我添加另一个ul时,它会选中所有的复选框。jQuery select/unselect all,但只在同一个元素内
$('#checkall').click(
function(){
$(this).closest('ul').find(':checkbox').attr('checked', this.checked);
$(this).closest('ul').find('span').toggleClass('checked', this.checked)
})
<div class="checks">
<ul>
<li><label for="checkall"><div class="checker"><span class=""><input type="checkbox" id="checkall" name="about"></span></div><strong>About our program</strong></label></li>
<li><label for="about1"><div class="checker"><span><input type="checkbox" id="about1" name="about"></span></div>CEO Message</label></li>
</ul>
</div>
不工作.. :(这里http://jsfiddle.net/upWxv/试试吧12/ – Mackelito 2011-12-15 08:10:44