input checkbox 全选

 <!DOCTYPE Html>  

 <html>  
 
    <head>  

         <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>  

         <script type="text/javascript">  
 
             function selectAll(checkbox) {  
 
                 $('input[type=checkbox]').attr('checked', $(checkbox).attr('checked'));  
 
             }  

         </script>  
 
     </head>  

     <body>  
 
         <input type="checkbox" onclick="selectAll(this);" />全选<br/>  
 
         <input type="checkbox"  /><br/>  
 
         <input type="checkbox"  /><br/>  
 
         <input type="checkbox"  /><br/>  
 
         <input type="checkbox"  /><br/>  
 
         <input type="checkbox"  /><br/>  
 
         <input type="checkbox"  /><br/>  
 

 
     </body>  
 
 </html

 
//全选
04 function select_all(){
05     $("input[name='id']").attr("checked", true);
06 }
07   
08 //全不选
09 function unselect_all(){
10     $("input[name='id']").attr("checked", false); 
11 }
12   
13 //反向选择
14 function select_other(){
15     jQuery.each($("input[name='id']"), function(i, n){
16     n.checked = !n.checked;
17     }); 
18 }
 
原文地址:https://www.cnblogs.com/sprine/p/4682173.html