比较简单实用,直接上代码,主要就是 lay-filter="ischange" 触发事件和 checkbox 的 class="ids" 对上就行:
Html:
<th>
	<input type="checkbox" id="ischange" lay-filter="ischange"/>
</th>
 
<td style="width:1%;">
<input type="checkbox" class="ids" name="tables"  value="${table.name!‘‘}" />
</td>
JS:
<script>
layui.use(‘form‘, function(){
	var form = layui.form;
	form.render(); //更新全部
	form.on(‘checkbox(ischange)‘,function(data){
		var a = data.elem.checked;
		if(a == true){
			$(".ids").prop("checked", true);
			form.render(‘checkbox‘);
		}else{
			$(".ids").prop("checked", false);
			form.render(‘checkbox‘);
		}
	});
	
});
</script>
原文:https://www.cnblogs.com/Keyifan/p/13604806.html