源码:

<input type="checkbox" id="cleckAll" />全选

<div class="list">

  <input type="checkbox" />复选一

  <input type="checkbox" />复选二

  <input type="checkbox" />复选三

</div>

 

脚本:

$('#cleckAll').click(function(){

  if($(this).is(':checked')){

    $('.list input').prop('checked',true);

  }else{

    $('.list input').prop('checked',false);

  }

})

 

注:这里用prop()  就别用 attr() 了, 否则你会很迷惘...

解:问题源了jQuery的版本问题,就不再详解了...

 

posted on 2016-07-10 11:08  小老虎网络  阅读(444)  评论(0编辑  收藏  举报