您的位置:首页 > Web前端 > JQuery

JQuery中全选与反选的

2015-08-18 18:24 696 查看
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" onclick="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);
});
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: