layui 绑定事件监听

版权声明:《==study hard and make progress every day==》 https://blog.csdn.net/qq_38225558/article/details/85372690

温馨小提示:如果是form表单的绑定事件监听,可参考官网文档:https://www.layui.com/doc/modules/form.html#on

下面是绑定普通事件

①html页面给你想要绑定的地方加上id或class属性,下面我以id举例

 <a class="iconfont icon-touxiang layui-hide-xs" id="zq_login"></a>

②js部分

$(function () {
    layui.use('layer', function(){
        var $ = layui.jquery
            ,layer = layui.layer //弹层

        //弹出登录页面
        $(document).on('click','#zq_login',function(){
            alert("这里写自己的功能...");
            /*layer.open({ //layer提供了5种层类型。可传入的值有:0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
                type: 2,
                title:"登录页面",
                area: ['55%','85%'],//类型:String/Array,默认:'auto'  只有在宽高都定义的时候才不会自适应
                fix: false, //不固定
                maxmin: true,//开启最大化最小化按钮
                shadeClose: true,//点击阴影处可关闭
                shade:0.4,//背景灰度
                skin: 'layui-layer-rim', //加上边框
                content: '/zq_blog/html/login_page/index.html',
                // resize:false
            });*/
        });

    });

});

猜你喜欢

转载自blog.csdn.net/qq_38225558/article/details/85372690