<div class="select">
<input type="checkbox" name="" id="all"><span>全选</span>
<br>
<input type="checkbox" name="" id="">
<input type="checkbox" name="" id="">
<input type="checkbox" name="" id="">
</div>
<script>
$('#all').click(function(){
// console.log($(this).is(':checked'));
if($(this).is(':checked')){
// alert('yes');
$('.select input[type="checkbox"]').each(function(){
if(!$(this).is(':checked')){
$(this).attr("checked",true);
}
})
}else{
$('.select input[type="checkbox"]').each(function(){
$(this).removeAttr("checked");
})
}
})
</script>
posted on 2018-04-20 16:31  ksy_c  阅读(176)  评论(0)    收藏  举报