HTML 简单事件绑定 ------- 隐藏盒子

  

 1 <html>
 2 <head >
 3     <meta charset="UTF-8">
 4     <title></title>
 5 </head>
 6 <body>
 7 <div class="box"></div>
 8 <script>
 9     //获取盒子,设置样式
10     var box = document.getElementsByClassName("box")[0];
11 //    box.style.width = "100px";
12 //    box.style.height = "100px";
13 //    box.style.backgroundColor = "pink";
14         box.style.cssText = "width:100px;height:100px;background-color:red";
15 
16     //隐藏盒子
17     box.onclick = function () {
18         this.style.display = "none";
19 //        this.style.visibility = "hidden";
20         this.style.opacity = "0";
21 //        this.style.position = "absolute";
22 //        this.style.top = "-50px";
23     }
24 
25 </script>
26 </body>
27 </html>