jquery各种操作复选框(全选、全不选、自动勾选、反选……)

  1. $('#checkAll').click(function(){  
  2.             if(this.checked) {  
  3.                 $("input[type=checkbox][name=ckjsmc]").each(function(){  
  4.                     $(this).attr('checked', 'true');  
  5.                 });  
  6.             } else {  
  7.                 $("input[type=checkbox][name=ckjsmc]").each(function(){  
  8.                     $(this).removeAttr('checked');  
  9.                 });  
  10.             }  
  11.         });  
  12.           
  13.      function checkOne(){  
  14.         var count = 0;  
  15.         $("input[type=checkbox][name=ckjsmc]").each(function(){  
  16.             if($(this).attr('checked') != 'checked'){// 判断一组复选框是否有未选中的  
  17.                 count+=1;  
  18.             }  
  19.         });  
  20.         if(count == 0) { // 如果没有未选中的那么全选框被选中  
  21.             $('#checkAll').attr('checked', 'true');  
  22.         } else {  
  23.             $('#checkAll').removeAttr('checked');  
  24.         }  
  25.      } 
posted @ 2018-04-19 10:14  雨夜_飞逃  阅读(320)  评论(0)    收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示