在主页面弹出一个弹出层

首先需要在页面引入jQuery1.8以上的任意版本,并引入layer.js

 <script>

$('#BtnLogin').on('click', function() {

        layer.open({
            title: false,
            type: 1,
            area: ['397px'],
            closeBtn: 0,
            shadeClose: true, //点击遮罩关闭
            content: '<div style="width:397px; background-color:#fcfcfc"> <form method="post" action="../UserInfo/login"><div><p align="center"> 账号 <input id="username" name="username" type="text" οnblur="ck()" /> </p> <div align="center"> 密码 <input id="password" name="password" type="password" /><br/><input type="button" οnclick="ckidpwd()" style="margin-top:15px;height:40px; width:170px;"class="layui-btn layui-btn-normal" value="登录"/><input type="submit" id="tjlogin" style="display: none" /></div> </form> <a id="qqLoginBtn"></a>'
        });
    });
</script>
content  内容

类型:String/DOM/Array

content可传入的值是灵活多变的,不仅可以传入普通的html内容,还可以指定DOM,更可以随着type的不同而不同。

以上为部分参数,详细参数请查看官网:http://www.layui.com/doc/modules/layer.html

完整代码示例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>layer弹出层</title>
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="layer/layer.js"></script>
</head>
 
<body>
      <a href="#" id="BtnLogin" style="float: right;margin-top:350px; margin-right:950px;font-size:20px;">点击弹出弹出层
<script>
//弹出登录子窗口
    $('#BtnLogin').on('click', function() {
        layer.open({
            title: false,
            type: 1,
            area: ['397px'],
            closeBtn: 0,
            shadeClose: true, //点击遮罩关闭
            content: '<div style="width:397px; background-color:#fcfcfc"> <form method="post" action="../UserInfo/login"><div><p align="center"> 账号 <input id="username" name="username" type="text" οnblur="ck()" /> </p> <div align="center"> 密码 <input id="password" name="password" type="password" /><br/><input type="button" οnclick="ckidpwd()" style="margin-top:15px;height:40px; width:170px;"class="layui-btn layui-btn-normal" value="登录"/><input type="submit" id="tjlogin" style="display: none" /></div> </form> <a id="qqLoginBtn"></a>'
        });
    });
</script>
</body>
</html>
复制到本地的时候需要将上面绿色字体js地址修改为本地js地址
效果图:
jQuery1.82.js  layer.js下载地址:链接:http://pan.baidu.com/s/1nuVmqRR 密码:l1tk
原文链接:http://lovecry.wang/Original/details?random=b93229ea-ca61-4322-b666-3734c2e42553
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值