JQuery中全选与反选的
2015-08-18 18:24
696 查看
JSP页面table的HTML代码:
JQuery代码:
<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); }); } }
相关文章推荐
- jQuery操作Select
- 【探索】用js打语言包(使用jquery.i18n.properties)
- 【探索】用js打语言包(使用jquery.i18n.properties)
- jquery tmpl 详解
- Jquery页面中添加键盘按键事件,如ESC事件
- jquery-chosen 选择框插件
- 一个简单的jQuery插件ajaxfileuplo 4000 ad实现ajax上传文件例子
- jQuery垂直多级导航菜单代码分享
- jquery相册图片来回选择
- jQuery Lazy Load 图片延迟加载
- jquery入门
- jquery selector 基础
- jquery实现选项在两个下拉列表之间选择性移动的功能
- jquery实现文本框默认值功能
- jquery实现复选框的全选与反选
- JQuery实现滑动开关效果
- jquery实现表单逐条登记,一次性提交功能
- jquery easyui树的简答构造+动态生成js全局变量
- jquery 验证
- jquery让页面中的模块自适应浏览器高度