Jquery实现全选和取消全选的方法
<input type="checkbox" id="all" />全选<br />
<input type="checkbox" name="permission" />添加权限<br />
<input type="checkbox" name="permission" />修改权限<br />
<input type="checkbox" name="permission" />权限列表<br />
<script>
$("#all").on('click',function() {
$("input[name='permission']").prop("checked", this.checked);
});
$("input[name='permission']").on('click',function() {
var $subs = $("input[name='permission']");
$("#all").prop("checked" , $subs.length == $subs.filter(":checked").length ? true :false);
});
</script>