码迷,mamicode.com
首页 > 其他好文 > 详细

element.parentNode案例:关闭模态框

时间:2019-12-20 15:11:05      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:模态框   ntb   click   isp   poi   ppi   one   pos   关闭   

 1 <!doctype html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <style>
 7         div {
 8             width: 400px;
 9             height: 400px;
10             border: 1px solid black;
11             background-color: pink;
12             position: relative; /*子绝父相*/
13         }
14 
15         #x {
16             width: 20px;
17             height: 20px;
18             position: absolute;
19             right: 5px;
20             top: 5px;
21             background-color: deeppink;
22             font-size: 18px;
23             line-height: 20px;
24             text-align: center;
25             cursor: pointer;
26         }
27     </style>
28 </head>
29 <body>
30 <div>
31     <span id="x">x</span>
32 </div>
33 <script>
34     let x = document.getElementById(x);
35     x.onclick = function () {
36         this.parentNode.style.display = none;
37     }
38 </script>
39 </body>
40 </html>

element.parentNode案例:关闭模态框

标签:模态框   ntb   click   isp   poi   ppi   one   pos   关闭   

原文地址:https://www.cnblogs.com/ustc-yy/p/12073133.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!