1.html页面:
var isSkipcheckbox = ‘‘; if (appOptions.isSkip != "0") { isSkipcheckbox = ‘checked=""‘; } <input type="checkbox" name="" lay-filter="type" lay-skin="primary" title="是否允许跳过" value="0" disabled="" ‘ + isSkipcheckbox + ‘>
2.layui form加载
layui.use(‘form‘, function () { var form = layui.form; //只有执行了这一步,部分表单元素才会修饰成功 form.render(‘checkbox‘); form.on(‘checkbox(type)‘, function (data) { if (data.elem.checked) { $(data.elem).val(1); var money = $(data.elem).parent().next().text(); if (money > 0) { console.log($("#money_total").val()); } } else { $(data.elem).val(0); var money = $(data.elem).parent().next().text(); if (money > 0) { // console.log($("#money_total").val()); } } ; //是否被选中,true或者false // $("#form").serialize() }); });