layui checkbox 监听

 普通单选框

监听

layui.use(['form', 'layer', 'jquery' ], function () {
$ = layui.jquery;
var layer = layui.layer,
    form = layui.form;
//监听多选框点击事件  主要是通过 lay-filter="switchTest"  来监听
form.on('checkbox(switchTest)', function (data) {
  console.log( data );  //打印当前选择的信息
    if( data.elem.checked){      //判断当前多选框是选中还是取消选中
        alert('当前选中');
    }
  var value = data.value;   //获取选中的value值
});
}

=================================================================================================================================================================================================

layui 单选框  开关  监听

    开关样式

  

监听开关

layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form;
            layer = layui.layer;
            layedit = layui.layedit;
            laydate = layui.laydate;


        form.on('switch(max_user_num1)', function(data){
            alert(data.elem.checked);
            return false;
            if(data.elem.checked==true){
                $("#max_user_num1").css('display','block');
            }else{
                $("#max_user_num1").css('display','none');
            }
        });

        //日期
        laydate.render({
            elem: '#start_time'
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#end_time'
            ,type: 'datetime'
        });

    });

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(js,layui,checkbox,checkbox)