首页 > Web开发 > 详细

用Jquery实现复选框的全选

时间:2016-10-13 09:40:50      阅读:249      评论:0      收藏:0      [点我收藏+]
<html>
<head>
<title>用Jquery实现复选框的全选</title>
<script src="../javascript/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function () {
$(function() {
$("#checkAll").click(function() {
$(input[name="subBox"]‘).attr("checked",this.checked);
});
var $subBox = $("input[name=‘subBox‘]");
$subBox.click(function(){
$("#checkAll").attr("checked",$subBox.length == $("input[name=‘subBox‘]:checked").length ? true : false);
});
});
})
</script>

</head>
<body>
<div>
<input id="checkAll" type="checkbox">全选
<input name="subBox" type="checkbox" />项1
<input name="subBox" type="checkbox" />项2
<input name="subBox" type="checkbox" />项3
<input name="subBox" type="checkbox" />项4
</div>

</body>
</html>

用Jquery实现复选框的全选

原文:http://www.cnblogs.com/Dionexin/p/5955091.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!