1. JS代码
  2. //全选  
  3. function upCheckAll(){  
  4.     if($("#upcheckboxall").attr("checked") == true) {      
  5.         $("input[name='upcheckbox']").each(  
  6.             function() {  
  7.                 if ( ! $(this).attr("disabled")){  
  8.                     $(this).attr("checked"true);   
  9.                 }  
  10.             }  
  11.         );   
  12.     }else{    
  13.         $("input[name='upcheckbox']").each(  
  14.             function() {  
  15.                 if ( ! $(this).attr("disabled")){  
  16.                     $(this).attr("checked"false);    
  17.                 }  
  18.             }  
  19.         );    
  20.     }   
  21. };  
  22.   
  23. //取消全选  
  24. function downCancelCheckAll(){  
  25.     if($("#upcheckboxall").attr("checked") == true){  
  26.         $("#upcheckboxall").attr("checked"false);  
  27.     }  
  28. }  

 

XML/HTML代码
  1. <table border="0" cellspacing="10" cellpadding="0" style="margin-left:200px;">  
  2.     <tr>  
  3.         <td><input type="checkbox" id="upcheckboxall" onclick="upCheckAll()" />td>  
  4.         <td>全选td>  
  5.     tr>  
  6.     <tr>  
  7.         <td><input name="upcheckbox" type="checkbox" onclick="downCancelCheckAll()" />td>  
  8.         <td>记录1td>  
  9.     tr>  
  10.     <tr>  
  11.         <td><input name="upcheckbox" type="checkbox" onclick="downCancelCheckAll()" />td>  
  12.         <td>记录2td>  
  13.     tr>  
  14. table>  

 

 posted on 2009-12-29 10:53  dongpo  阅读(278)  评论(0编辑  收藏  举报