zoukankan      html  css  js  c++  java
  • Layer(Web弹窗)

    Layer弹窗的用法:
    <script src="jQuery的路径"></script> <!-- 你必须先引入jQuery1.8或以上版本 -->
    <script src="layer.js的路径"></script>

    Layer的open方法:

    <!DOCTYPE html>
    <html>
        <head>
            <title>TODO supply a title</title>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <script src="http://cdn.bootcss.com/jquery/1.12.3/jquery.min.js"></script>
            <script src="js/layer/layer.js" type="text/javascript"></script>
        </head>
        <body>
            <style>
                .test{width: 300px; height: 300px; background:#ddd; color: #ff0000; margin:200px auto; text-align: center; font-size: 16px; font-family:Microsoft YaHei;}
                fieldset{border: none; border-top: 1px solid #333;}
            </style>
            <div class="test" style=" color: #ff0000;">
                <fieldset>
                    <legend>这是弹窗测试页面</legend>
                    <p>这是弹窗测试页面</p>
                    <input type="button" value="点击触发弹窗" class="testlayer">
                </fieldset>
            </div>
            
            <script>
                $(function(){
                layer.config({
                    skin: 'layui-layer-lan'
                  })
                /*layer.open({
                    //skin: 'demo-class'
                  });*/
                $(".testlayer").on("click",function(){
                    layer.open({
                    type: 1,
                    title:"测试",
                    closeBtn:0, //右上角关闭按钮
                    //skin: 'layui-layer-rim', //加上边框
                    area: ['450px', '250px'], //宽高
                    anim:2,//弹出动画
                    btn:['确定购买','取消购买'],//按钮
                    content: '<p style=" text-align: center;">html内容</p>',//弹窗内容
                    //maxmin:true,//最大最小化按钮
                    resize:false,//是否允许拉伸
                    yes:function(index,layerdom){
                        layer.close(index);
                        console.log("你点击了确定按钮");
                    },
                    btn2:function(index,layerdom){
                        console.log("你点击了取消按钮");//输出日志
                        //return false;//开启该代码可以禁止点击该按钮关闭
                    },
                    cancel:function(index,layerdom){
                        console.log("你点击了右上角的关闭按钮");
                    }
                  });
                });
                
                })
            </script>
        </body>
    </html>
    个人网站:http://shibowl.top
    github:https://github.com/hanbinjxnc
    博客园:https://www.cnblogs.com/hool
    个人博客:https://blog.shibowl.top
    作者:世博 2019年4月28日
  • 相关阅读:
    Maven相关知识片
    fastjson使用
    Block pool ID needed, but service not yet registered with NN java.lang.Exception: trace 异常解决
    JVM之内存结构详解
    ContextCleaner ——Spark 应用程序的垃圾回收器
    重新认识Java 8的HashMap
    HDFS NameNode内存全景
    HDFS的NameNode与SecondaryNameNode的工作原理
    大数据——基础知识
    HDFS数据定期清理
  • 原文地址:https://www.cnblogs.com/hool/p/10839855.html
Copyright © 2011-2022 走看看