<!--第一层-->
<div class="first">
<div class="first_top">
<img src="../img/chartor4.png" class="first-img" />
<input type="checkbox" name="resUuids" value="" id="all" class="first-inp" />
<span>OM系统</span>
</div>
<!--第二层-->
<div class="second">
<div class="second_top">
<img src="../img/chartor5.png" class="second-img" />
<input type="checkbox" name="resUuid" value="" class="second-inp per-index" />
<span>发货方管理</span>
</div>
<!--第三层-->
<div class="third">
<div class="thired_top">
<input type="checkbox" name="resUuids" value="" class="third-inp"/>
<span>查询货主</span>
</div>
<div class="thired_top">
<input type="checkbox" name="resUuids" value="" class="third-inp"/>
<span>查询货主</span>
</div>
<div class="thired_top">
<input type="checkbox" name="resUuids" value="" class="third-inp" />
<span>查询货主</span>
</div>
</div>
</div>
</div>

  

.first {
overflow: hidden;
margin-left:10%;
}
.first_top {
font-size: 16px;
}
.first_top img {
float: left;
margin-right: 10px;
cursor: pointer;
}
.first_top input {
width: 18px;
height: 18px;
border:1px solid #ccc;
background: #fff !important;
float: left;
background-color: #f4a100 !important;
margin-right: 10px;
}
.second_top {
font-size: 16px;
margin-left: 4%;
margin-top: 1%;
}
.second_top img {
float: left;
margin-right: 10px;
cursor: pointer;
}
.second_top input {
width: 18px;
height: 18px;
box-sizing: border-box;
border:1px solid #ccc;
background: #fff !important;
float: left;
background-color: #f4a100;
margin-right: 10px;
}
.thired_top {
font-size: 16px;
margin-left: 12%;
margin-top: 1%;
}
.thired_top img {
float: left;
margin-right: 10px;
}
.thired_top input {
width: 18px;
height: 18px;
box-sizing: border-box;
border:1px solid #ccc;
background: #fff !important;
float: left;
background-color: #f4a100;
margin-right: 10px;
}

  第一种:子级盒子全选中父级盒子选中

//盒子折叠
//第一层
$(".first-img").click(function(){
$(this).parent().siblings().slideToggle(500);
});
//第二层
$(".second-img").click(function(){
$(this).parent().siblings().slideToggle(500);
}); //全选反选
//第一层全选
$("#all").click(function() {
var op = $(this).parent().siblings().find("input[name='resUuids']");
var pp = $(this).parent().siblings().find("input[name='resUuid']");
op.prop("checked", this.checked);
pp.prop("checked", this.checked); });
//第二层全选
$(".second-inp").click(function() {
var op = $(this).parent().siblings().find("input[name='resUuids']");
op.prop("checked", this.checked);
});
//第三层反选
$(".third-inp").click(function() {
var lb = $(this).parent().parent().find('.third-inp');
var all = $(this).parent().parent().parent().parent().find('.second-inp');
//给第二层盒子加上选中
for(var i=0;i<lb.length;i++){
// if($(lb[i]).prop("checked") == true){
// $(this).parent().parent().siblings().find('.second-inp').prop("checked", true);
// break
// }else{
// $(this).parent().parent().siblings().find('.second-inp').prop("checked", false);
// }
if($(lb[i]).prop("checked") == false){
$(this).parent().parent().siblings().find('.second-inp').prop("checked", false);
break
}else{
$(this).parent().parent().siblings().find('.second-inp').prop("checked", true);
}
} //给第一层盒子加上选中
for(var j=0;j<all.length;j++){
if($(all[j]).prop("checked") == false){
$(this).parent().parent().parent().parent().find('.first-inp').prop("checked", false);
break ;
}else{
$(this).parent().parent().parent().parent().find('.first-inp').prop("checked", true);
}
}
});
//第二层反选
$(".per-index").click(function() {
var nb = $(this).parent().parent().parent().find('.per-index');
for(var i=0;i<nb.length;i++){
if($(nb[i]).prop("checked") == false){
$(".first-inp").prop("checked", false);
return ;
}else {
$(".first-inp").prop("checked", true);
}
}
});

  第二种:子级盒子只要有一个被选中父级盒子就被选中

//盒子折叠
//第一层
$(".first-img").click(function(){
$(this).parent().siblings().slideToggle(500);
});
//第二层
$(".second-img").click(function(){
$(this).parent().siblings().slideToggle(500);
}); //全选反选
//第一层全选
$("#all").click(function() {
var op = $(this).parent().siblings().find("input[name='resUuids']");
var pp = $(this).parent().siblings().find("input[name='resUuid']");
op.prop("checked", this.checked);
pp.prop("checked", this.checked); });
//第二层全选
$(".second-inp").click(function() {
var op = $(this).parent().siblings().find("input[name='resUuids']");
op.prop("checked", this.checked);
});
//第三层反选
$(".third-inp").click(function() {
var lb = $(this).parent().parent().find('.third-inp');
var all = $(this).parent().parent().parent().parent().find('.second-inp');
//给第二层盒子加上选中
for(var i=0;i<lb.length;i++){
if($(lb[i]).prop("checked") == true){
$(this).parent().parent().siblings().find('.second-inp').prop("checked", true);
break
}else{
$(this).parent().parent().siblings().find('.second-inp').prop("checked", false);
}
// if($(lb[i]).prop("checked") == false){
// $(this).parent().parent().siblings().find('.second-inp').prop("checked", false);
// break
// }else{
// $(this).parent().parent().siblings().find('.second-inp').prop("checked", true);
// }
} //给第一层盒子加上选中
for(var j=0;j<all.length;j++){
if($(all[j]).prop("checked") == false){
$(this).parent().parent().parent().parent().find('.first-inp').prop("checked", false);
break ;
}else{
$(this).parent().parent().parent().parent().find('.first-inp').prop("checked", true);
}
}
});
//第二层反选
$(".per-index").click(function() {
var nb = $(this).parent().parent().parent().find('.per-index');
for(var i=0;i<nb.length;i++){
if($(nb[i]).prop("checked") == false){
$(".first-inp").prop("checked", false);
return ;
}else {
$(".first-inp").prop("checked", true);
}
}
});

  

html中全选反选的更多相关文章

  1. 关于Winform下DataGridView中实现checkbox全选反选、同步列表项的处理

    近期接手一个winform 项目,虽然之前有.net 的经验,但是对一些控件的用法还不是很熟悉. 这段时间将会记录一些在工作中遇到的坎坷以及对应的解决办法,写出来与大家分享并希望大神提出更好解决方法来 ...

  2. React中的全选反选问题

    全选反选问题 1.在state里维护一个数组,例如showArr:[] 2.绑定点击事件的时候将当前这个当选按钮的index加进来 <span className='arrow' onClick ...

  3. JQuery 全选 反选 获取Table 中指定td的元素值

    //全选 function initTableCheckbox() { var $thr = $('table thead tr'); var $checkAllTh = $('<th>& ...

  4. BootStrapt iCheck表单美化插件使用方法详解(含参数、事件等) 全选 反选

    特色: 1.在不同浏览器(包括ie6+)和设备上都有相同的表现 — 包括 桌面和移动设备 2.支持触摸设备 — iOS.Android.BlackBerry.Windows Phone等系统 4.方便 ...

  5. 用javascript实现全选/反选组件

    以下是本人制作的全选/反选 组件,供广大同行参考.指正: 效果如图: 在实现的过程中,全选和全部取消选中这两个功能较为简单,只需用for循环遍历所有复选框为true或false即可.反选也较为简单,也 ...

  6. jquery、js操作checkbox全选反选

    全选反选checkbox在实际应用中比较常见,本文有个不错的示例,大家可以参考下 操作checkbox,全选反选//全选 function checkAll() { $('input[name=&qu ...

  7. 关于JQuery全选/反选第二次失效的问题

    最近在项目中,遇到一个问题,测试全选/反选功能时,第一次对母框进行选中/非选中时,能同步子框的全选/反选状态,之后再点击母框,子框就没反应了.原代码大致结构关键如下: function selectA ...

  8. jQuery之标签操作和返回顶部、登录验证、全选反选、克隆示例

    一.样式操作 1.JQ中的样式类 somenode.addClass();// 添加指定的CSS类名. somenode.removeClass();// 移除指定的CSS类名. somenode.h ...

  9. Android开发 ---基本UI组件5:监听下拉选项,动态绑定下拉选项、全选/反选,取多选按钮的值,长按事件,长按删除,适配器的使用,提示查询数据,activity控制多按钮

    效果图: 效果描述: 1.当点击 1 按钮后,进入选择城市的页面,会监听到你选中的城市名称:动态为Spinner绑定数据 2.当点击 2 按钮后,进入自动查询数据页面,只要输入首字母,就会动态查找以该 ...

随机推荐

  1. maven pom.xml设置jdk编译版本为1.8

    <build> <finalName>myweb</finalName> <plugins> <!--JDK版本 --> <plugi ...

  2. 三十九:数据库之SQLAlchemy.relationship方法中的cascade参数

    在SQLAlchemy中,只要将一条数据添加到session中,其它和此条数据相关联的数据都会一起存到数据库中,这是因为在relationship中有一个关键字参数:cascade,默认选项为save ...

  3. 短信验证码api

    最近遇到的项目需要个随机短信验证码实现注册用户 选用的是“云信使”,因为有15条免费的测试短信可以验证代码是否正确调用该短信api 地址 进入短信平台 一.实名认证 + 短信模板 用户认证完成后,创建 ...

  4. python线程池--threadpool

    在爬虫时,有时候解析获得了很多图片或视频地址时,如果一个个下载完成再去下载另一个,这样执行效率太慢了,此时就可用到线程池threadpool,使用基本步骤如下: 1.定于任务函数 2.创建线程池,定义 ...

  5. 【VS开发】动态添加的ActiveX控件如何响应事件

    http://blog.csdn.net/xiaoqiqixiao/article/details/574542 今天在csdn上看到一朋友问如何响应动态添加的控件的事件,搜索资料,发现对于一般的应用 ...

  6. 深入理解java:2.3.4. 并发编程concurrent包 之容器ConcurrentLinkedQueue(非阻塞的并发队列---循环CAS)

    1.    引言 在并发编程中我们有时候需要使用线程安全的队列. 如果我们要实现一个线程安全的队列有两种实现方式:一种是使用阻塞算法,另一种是使用非阻塞算法. 使用阻塞算法的队列可以用一个锁(入队和出 ...

  7. 【Sass】常用知识点总结

    如何编译Sass Partials Variables colors font stacks 全局变量 Mixins 全局mixin 推荐的mixin插件 Bourbon Extend/Inherit ...

  8. xmake从入门到精通9:交叉编译详解

    xmake是一个基于Lua的轻量级现代化c/c 的项目构建工具,主要特点是:语法简单易上手,提供更加可读的项目维护,实现跨平台行为一致的构建体验. 除了win, linux, macOS平台,以及an ...

  9. 红帽学习笔记[RHCSA] 第二周

    目录 红帽学习笔记[RHCSA]第二周 环境 第七课[网络配置相关] 在Vmware中添加网卡 将网卡添加到虚拟机上 关于网卡命名规则 配置网络 网络配置命令总结 更改hostname 关于SSH的一 ...

  10. centos7 中如何查看、打开、关闭防火墙。

    首先是看centos7的防火墙的状态,查看的命令为: sudo systemctl status firewalld. 查看后,看到active(running)就意味着防火墙打开了, 如果想关闭防火 ...