HTML代码:
<input type="checkbox" name="all" id="all">全选 <input type="checkbox" name="id[]"> <input type="checkbox" name="id[]"> <input type="checkbox" name="id[]">
JS代码:
$(function(){
$('#all').on('click',function(){
$("input[name='id[]']").prop("checked", this.checked);
});
$("input[name='id[]']").on('click',function() {
var $subs = $("input[name='id[]']");
$("#all").prop("checked" , $subs.length == $subs.filter(":checked").length ? true :false);
});
});
上一篇:点击链接平滑到指定位置 滚动插件jquery.smoothScroll
下一篇:Jquery获取当前元素父元素
讨论数量:0