layui实现复选框全选,反选

html

<div class="layui-input-inline">
<input type="checkbox" class="checkboxAll" lay-skin="primary" lay-filter="allChoose" title='全选'>
</div>
<input type="checkbox" name="check[]" value="{$item.id}" lay-skin="primary" title="{$item.type_name}" lay-filter="oneChoose">
<input type="button" id="sub" class="layui-btn" value="确认添加">

js

layui.use(['layer','form'], function () {
var form = layui.form
,layer = layui.layer; form.on('checkbox(allChoose)', function (data) {
$("input[name='check[]']").each(function () {
this.checked = data.elem.checked;
// console.log(data);
});
form.render('checkbox');
}); }); $('#sub').click(function(){
var items =[];
$("input[name='check[]']:checked").each(
function(){
items.push($(this).val());
})
console.log(items);
})

layui实现复选框全选,反选

上一篇:Error creating bean with name 'redisTemplate' defined in URL


下一篇:int(a) 和 (int &) a 及 数据存储地址的探究