代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
html {
margin: 0px;
padding: 0px;
height: 0px;
position: relative;
top: 0px;
}
body {
position: relative;
margin: 0px;
top: -16px;
}
div {
width: 200px;
height: 100px;
background-color: green;
/*display: none;*/
}
ul li {
list-style: none;
position: absolute;
}
.register {
top: 40px;
}
</style>
</head>
<body>
<!--<div id="" >
注册成功
</div>-->
<ul>
<li class="login">登录</li>
<li class="register">注册</li>
</ul>
</body>
</html>
<script src="jquery.js"></script>
<script src="弹窗.js"></script>
<script>
//方法一
$.fn.extend({
popup: function(text) {
$(this).on("click", function() {
var sec = document.createElement("section")
$(sec).css({
"width": "100%",
"height": "100vh",
"background": "gray",
"opacity": "0.5",
"z-index": "10",
"position": "absolute",
})
document.body.append(sec)
var div = document.createElement("div")
$(div).css({
"width": "200px",
"height": "100px",
"border": "1px solid red",
"z-index": "20",
"position": "absolute",
"top": "300px",
"left":"45%",
"text-align": "center",
"line-height":"100px"
}).text(text)
document.body.append(div)
console.log($("div").length)
var btn = document.createElement("button")
div.append(btn)
$(btn).css({
"width": "20px",
"height": "20px",
"background": "red",
"color": "#ffffff",
"z-index": "30",
"position": "absolute",
"right": "0px",
}).text("x")
$(btn).on("click", function() {
$(div).css("display", "none")
$(sec).css("display", "none")
})
})
}
})
////方法二
//
//$.fn.extend({
// popup: function(text){
// $(this).on("click",function () {
// alert(text)
// })
// }
//})
$("ul .login").popup("登录成功")
$("ul .register").popup('注册成功')
</script>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。