checkbox树显示,全选和反选
来源:互联网 发布:复活岛巨人像 知乎 编辑:程序博客网 时间:2024/06/05 00:28
今天做项目遇到一个需求需要把一些单位的层级在页面展现并附有chekbox选项框,支持全选和反选图示:
效果实现代码:
<table style="border-weight: 0px!important;" border="0" cellpadding="0px" cellspacing="8px" ><c:forEach items="${unsign}" var="orgp" varStatus="gstatus"><tr class="${orgp.id}"><td style="border-width: 0px;"> <label> <input style="margin-top: 0px;" type="checkbox" value="${orgp.orgName}" name="parentAddress" id="${orgp.id}"/><span class="" style="font-weight:bold">${orgp.orgName}</span> </label></td><c:forEach items="${orgp.childs}" var="child" varStatus="accountStatus"><c:if test="${accountStatus.count==1}"><tr class="${orgp.id}" style="border-width: 0px;"></c:if><td width="120px" style="padding-left:13px; border-width: 0px;"><label><input id="${child.c_id}" style="margin-top: 0px;" type="checkbox" value="${child.c_id}" name="address" /><span class="${child.c_id}">${child.c_recivername}</span></label></td><c:if test="${(accountStatus.count)%4==0}"><tr class=""></tr></c:if><c:if test="${(accountStatus.count)%4!=0&&accountStatus.last}"> <tr class=""></tr></c:if> </c:forEach> </tr></c:forEach> </table>全选和反选代码:
//全选/反选 $("input[name='uparentAddress']").on('click',function(){if(this.checked){$('tr[class='+$(this).parents('tr').attr('class')+']').find("input[name='uaddress']").each(function(){$(this).prop("checked",true);});}else{$('tr[class='+$(this).parents('tr').attr('class')+']').find("input[name='uaddress']").each(function(){$(this).prop('checked',false);});}});单选
$("input[name='address']").on('click',function(){var flag = true;var aa = $(this).parents('tr').attr('class');var p = $(this).parents('tr').parents('tr').find('input[id="'+aa+'"]');$(this).parents('tr').find('.'+aa).find('input[name="address"]').each(function(){if($(this).prop('checked')==false){flag = false;}});if(flag==true){p.prop('checked',true);}else{p.prop('checked',false);}});获取checkbox选中的值:
var id='';$('input[name="address"]:checked').each(function(){id += $(this).val()+",";});
0 0
- checkbox树显示,全选和反选
- checkbox全选和反选
- checkbox全选和反选
- checkbox全选和反选
- checkbox全选和反选
- checkbox 全选和反选
- checkbox全选和反选
- Checkbox全选和反选
- checkbox全选,反选和取消全选
- checkbox全选反选
- checkbox 全选 反选
- checkbox全选反选
- checkbox,全选,反选
- checkbox全选反选
- checkbox的全选和反选
- jQuery实现checkbox全选和反选
- checkBox的全选和 反选
- jquery全选和反选checkbox
- Jenkins进阶系列之——17Jenkins升级、迁移和备份
- 数据库隔离级别
- Jsoup解析Html教程
- CentOS中无法使用setup命令 -bash:setup: command not found
- 新特性:TabLayout动态添加条目
- checkbox树显示,全选和反选
- csv 中 数值被自动转换成科学计数法 的问题 excel打开后数字用科学计数法显示且低位变0的解决方法
- Android面试常见问题及解答
- PHP--swoole
- static关键字的作用
- Hello world!
- eclipse jdk配置与安装后错误 java was started but returned exit code=13
- 基于Cesium的一些demo
- web数据存储