layui table monitor switch and get diverted id

 ,{field:'sex', title:'性别', width:85, templet: '#switchTpl', unresize: true}

 

<script type="text/html" id="switchTpl">
<!-- 这里的 checked 的状态只是演示 -->
<input type="checkbox" name="sex" value="{{d.id}}" lay-skin="switch" lay-text="女|男" lay-filter="sexDemo" {{ d.id == 10003 ? 'checked' : '' }}>
</script>

 

form.on('switch(sexDemo)', function(obj){

this.value: diverted id

obj.elem.value: checkbox的值
layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);
});

Guess you like

Origin www.cnblogs.com/hssds/p/11736377.html