JQuery中全选与反选的

JSP页面table的HTML代码:
<table style="color:#000;border-collapse: collapse;width: 100%;border-color: red;" border="1"  >
	<tr><th>序号</th><th>附件名</th><th>是否发送[全选<input type="checkbox" name="allCheck" value="111" οnclick="doSelectAll(this);" /> ]</th></tr>
<span style="white-space:pre">		</span>
<span style="white-space:pre">	</span><%	for(Iterator iterator = attachColl.iterator(); iterator.hasNext();){ attachIndex++;EntityMap attMap = (EntityMap) iterator.next();%>
			
<span style="white-space:pre">	</span><tr><td><%=attachIndex %></td><td align="left"><%=attMap.getJspString("fsfilename")%></td>
<span style="white-space:pre">		</span><td><input type="checkbox" name="atach" value="<%=attMap.getJspString("fsid")%>"  /> </td> </tr>
		<%} %>
							</table>



JQuery代码:

	function doSelectAll(obj){
		if($("input[name=allCheck]").get(0).checked){//点击全选
			$("input[name=atach]").each(function(){
	 			$(this).attr('checked', true);
	 		});
		}else{//取消全选
			$("input[name=atach]").each(function(){
	 			$(this).attr('checked', false);
	 		});
		}
 	} 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值