全选反选

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="list">
<ul class="mui-table-view textOverflow" id="notesList" >
<li><input type="checkbox" class="check" name="notices" value="1"> 篮球</li>
<li><input type="checkbox" class="check" name="notices" value="1"> 足球</li>
<li><input type="checkbox" class="check" name="notices" value="1"> 乒乓球</li>
<li><input type="checkbox" class="check" name="notices" value="1"> 羽毛球</li>
<li><input type="checkbox" class="check" name="notices" value="1"> 排球</li>
</ul>
</div>
<input type="checkbox" value="全选" class="btn" id="selectAll">全选
</body>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>
$("#selectAll").off().on('click',function(){
var $that = $(this),
$myLi = $("ul li");
$myLi.each(function(index){
var check = $myLi.find(".check");
if($that.is(':checked')){
check.prop('checked',true);
}else{
check.prop('checked',false);
}
check.click(function(){
if($(this).is(":checked")){

}
else{
$that.prop('checked',false);
}
})
})
})

</script>
</html>

posted @ 2016-07-12 17:22  往昔-安安  阅读(88)  评论(0编辑  收藏  举报