日期:2014-05-16  浏览次数:20324 次

checkbox全选/取消全选的问题
<html>
<head>
<script src="./js/jquery.min.js"></script>
<script>
$(function(){
$("#b").click(function(){
 $(":checkbox").removeAttr("checked");
});
$("#c").click(function(){
 $(":checkbox").attr("checked",'true');
});
});
</script>
</head>
<body>
<input type="checkbox" id="check1">check1<br>
<input type="checkbox" id="check2">check2<br>
<input type="checkbox" id="check3">check3<br>
<input type="checkbox" id="check4">check4<br>
<input id="b" type="button" value="取消全选" />
<input id="c" type="button" value="全选" />
</body>
</html>


点击全选,有效果,点击取消全选,没问题,可是再点全选就没用了,请大神们看看

------解决方案--------------------
 $(":checkbox").prop("checked",false);
 $(":checkbox").prop("checked",'true');