<body>
<form method="post" action="">
你爱好的运动是?<input type="checkbox" id="checkedAll_2" />全选/全不选
<br/>
<input type="checkbox" name="items" value="篮球" />
<input type="checkbox" name="items" value="足球" />
<input type="checkbox" name="items" value="羽毛球" />
<input type="checkbox" name="items" value="乒乓球" />
<form>
</body>
<script>
$(function(){
//控制篮球足球。。。。。
$("#checkedAll_2").click(function(){
var flag = this.checked;
$(":checkbox[name='items']").attr("checked",flag);
});
//控制全选/全不选
$(":checkbox[name='items']").click(function(){
$("#checkedAll_2").attr("checked",
$(":checkbox[name='items']").length == $(":checkbox[name='items']:checked"));
})
}