Home  >  Article  >  Web Front-end  >  How to bind common event listeners in layui

How to bind common event listeners in layui

王林
王林forward
2020-11-26 15:37:342644browse

How to bind common event listeners in layui

How to bind ordinary events:

Add id or class attributes to the html page where you want to bind. I will use id as an example below

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

js code

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

Related recommendations: layui

The above is the detailed content of How to bind common event listeners in layui. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete