layui复选框全选,单选取消全选

<!--html代码-->

<div class="layui-form-item">

<label class="layui-form-label">业主承担费用</label>
<div class="layui-input-block">
<input type="checkbox"  name="ownerCost" lay-skin="primary" id="owner_all"    lay-filter="owner_all" title="全选" value="(1)-(10)"> 
<input type="checkbox" id="ownerCost2" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="水费" value="(1)"> 
<input type="checkbox" id="ownerCost3" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="电费" value="(2)"> 
<input type="checkbox" id="ownerCost4" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="有线电视费" value="(3)"> 
<input type="checkbox" id="ownerCost5" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="供暖费" value="(4)"> 
<input type="checkbox" id="ownerCost6" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="煤/燃气费" value="(5)"> 
<input type="checkbox" id="ownerCost7" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="物业管理费" value="(6)"> 
<input type="checkbox" id="ownerCost8" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="卫生费" value="(7)"> 
<input type="checkbox" id="ownerCost9" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="上网费" value="(8)"> 

<input type="checkbox" id="ownerCost10" name="ownerCost" lay-skin="primary" class="ownerCost" lay-filter="owner_one" title="因居住而发生的费用(含公共电费等)" value="(9)">

<input type="checkbox" id="ownerCost11" name="ownerCost" lay-skin="primary" class="ownerPublic" lay-filter="owner_public" title="公产房房费" value="(10)">

<input type="checkbox" id="ownerCost12" name="ownerCost" lay-skin="primary" class="ownerOther" lay-filter="owner_other" title="其他费用" value="(11)"> 

</div>

</div>

 

<!--js代码-->

//委托人费用全选
form.on('checkbox(owner_all)', function(data){
var a = data.elem.checked;
if(a == true){
$(".ownerCost").prop("checked", true);
form.render('checkbox');
}else{
$(".ownerCost").prop("checked", false);
form.render('checkbox');
}

});
//委托人费用有一个未选中全选取消选中
form.on('checkbox(owner_one)', function(data){
var item = $(".ownerCost");
for(var i=0;i<item.length;i++){
if(item[i].checked == false){
$("#owner_all").prop("checked", false);
form.render('checkbox');
}
}
});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值