纯JS实现弹出框
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>纯JS实现弹出框</title>
<style type="text/css">
/*弹出层*/
.popPosition {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
#pop-container {
display: none;
z-index: 999;
}
/*遮盖层*/
#cover-tier {
background-color: #D9D9D9;
opacity: 0.5;
}
/*弹出层内容*/
#pop-tier {
width: 100px;
height: 50px;
border: 5px solid #C3C3C3;
background-color: #fff;
margin: auto;
text-align: center;
}
#pop-tier>p {
margin-top: 10px;
}
</style>
</head>
<body>
<button id="btn">点击弹出层</button>
<div id="pop-container">
<div id="cover-tier"></div>
<div id="pop-tier">
<p id="alert">弹出框内容</p>
</div>
</div>
<script type="text/javascript">
function temp(id) {
return document.getElementById(id);
}
// 点击按钮出现弹出层
temp('btn').onclick = function() {
//temp("alert").innerHTML = msg;
temp('pop-container').style.display = 'block';
};
// 弹出层隐藏
temp('pop-tier').onclick = function() {
temp('pop-container').style.display = 'none';
};
temp('cover-tier').onclick = function() {
temp('pop-container').style.display = 'none';
};
</script>
</body>
</html>
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇