标签:false asc name 全选 put click family length class
<body>
<div class="div1">
<input type="checkbox" name="cb">
</div>
<hr>
<div class="div2">
<input type="checkbox" name="cbs"><br>
<input type="checkbox" name="cbs"><br>
<input type="checkbox" name="cbs"><br>
<input type="checkbox" name="cbs">
</div>
</body>
<script type="text/javascript">
var num=0;
$("input[name=‘cb‘]").click(function(){
if($(this).attr("checked")=="checked"){
$("input[name=‘cbs‘]").attr("checked",true);
num=$("input[name=‘cbs‘]").length;
}else{
$("input[name=‘cbs‘]").attr("checked",false);
num=0;
}
})
$("input[name=‘cbs‘]").click(function(){
if($(this).attr("checked")=="checked"){
num++;
if(num==$("input[name=‘cbs‘]").length){
$("input[name=‘cb‘]").attr("checked",true);
}
}else{
num--;
$("input[name=‘cb‘]").attr("checked",false);
}
})
</script>
标签:false asc name 全选 put click family length class
原文地址:http://www.cnblogs.com/pengyan89/p/6907749.html