input checkbox 全选

 1  <! DOCTYPE Html >  
 2 
 3 02  < html >  
 4 
 5 03      < head >  
 6 
 7 04          < script  type ="text/javascript"  src ="http://code.jquery.com/jquery-1.4.4.min.js" ></ script >  
 8 
 9 05          < script  type ="text/javascript" >   
10 
11  06               function  selectAll(checkbox) {  
12 
13  07                  $( ' input[type=checkbox] ' ).attr( ' checked ' , $(checkbox).attr( ' checked ' ));  
14 
15  08              }  
16 
17  09           </ script >  
18 
19 10      </ head >  
20 
21 11      < body >  
22 
23 12          < input  type ="checkbox"  onclick ="selectAll(this);"   />全选 < br />  
24 
25 13          < input  type ="checkbox"    />< br />  
26 
27 14          < input  type ="checkbox"    />< br />  
28 
29 15          < input  type ="checkbox"    />< br />  
30 
31 16          < input  type ="checkbox"    />< br />  
32 
33 17          < input  type ="checkbox"    />< br />  
34 
35 18          < input  type ="checkbox"    />< br />  
36 
37 19         ……  
38 
39 20      </ body >  
40 
41 21  </ html > 
 
//全选
04function select_all(){
05    $("input[name='id']").attr("checked", true);
06}
07  
08//全不选
09function unselect_all(){
10    $("input[name='id']").attr("checked", false); 
11}
12  
13//反向选择
14function select_other(){
15    jQuery.each($("input[name='id']"), function(i, n){
16    n.checked = !n.checked;
17    }); 
18}

转载于:https://www.cnblogs.com/dangqinghua/archive/2012/04/22/2465282.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值