<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$(".checkAll").click(function(){
$('input[name="subBox"]').prop("checked",this.checked);
});
var $subBox = $("input[name='subBox']");
$subBox.click(function(){
$(".checkAll").prop("checked",$subBox.length == $("input[name='subBox']"))
})
})
</script>
</head>
<body>
<div>
<input class="checkAll" type="checkbox"/>全选
<input class="delete" type="button" value="删除" />
<br/>
<input name="subBox" type="checkbox" />选项一
<br/>
<input name="subBox" type="checkbox" />选项
<br/>
<input name="subBox" type="checkbox" />选项三<br/>
<input name="subBox" type="checkbox" />选项四
</div>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$(".checkAll").click(function(){
$('input[name="subBox"]').prop("checked",this.checked);
});
var $subBox = $("input[name='subBox']");
$subBox.click(function(){
$(".checkAll").prop("checked",$subBox.length == $("input[name='subBox']"))
})
})
</script>
</head>
<body>
<div>
<input class="checkAll" type="checkbox"/>全选
<input class="delete" type="button" value="删除" />
<br/>
<input name="subBox" type="checkbox" />选项一
<br/>
<input name="subBox" type="checkbox" />选项
<br/>
<input name="subBox" type="checkbox" />选项三<br/>
<input name="subBox" type="checkbox" />选项四
</div>
</body>
</html>