zoukankan      html  css  js  c++  java
  • 3.关闭京东广告栏

     1 <!DOCTYPE html>
     2 <html>
     3 <head lang="en">
     4     <meta charset="UTF-8">
     5     <title></title>
     6     <style>
     7         * {
     8             padding: 0;
     9             margin: 0;
    10         }
    11         .top-banner {
    12             background-color: pink;
    13             height: 80px;
    14         }
    15         .w {
    16              1210px;
    17             margin: 10px auto;
    18             position: relative;
    19         }
    20         img {
    21              1210px;
    22             height: 80px;
    23             background-color: blue;
    24         }
    25         a {
    26             position: absolute;
    27             top: 5px;
    28             right: 5px;
    29             color: #fff;
    30             background-color: #000;
    31             text-decoration: none;
    32              20px;
    33             height: 20px;
    34             font: 700 14px/20px "simsum";
    35             text-align: center;
    36         }
    37         .hide {
    38             display: none!important;
    39         }
    40     </style>
    41     <!--<script>-->
    42         <!--window.onload = function () {-->
    43             <!-- -->
    44         <!--}-->
    45     <!--</script>-->
    46 </head>
    47 <body>
    48     <div class="top-banner" id="topBanner">
    49         <div class="w">
    50             <img src="" alt=""/>
    51             <a href="#" id="closeBanner">×</a>
    52         </div>
    53     </div>
    54 
    55 
    56 <script>
    57     //需求:点击案例,隐藏盒子。
    58     //思路:点击a链接,让top-banner这个盒子隐藏起来(加隐藏类名)。
    59     //步骤:
    60     //1.获取事件源和相关元素
    61     //2.绑定事件
    62     //3.书写事件驱动程序
    63 
    64 
    65     //1.获取事件源和相关元素
    66     var closeBanner = document.getElementById("closeBanner");
    67     var topBanner = document.getElementById("topBanner");
    68     //2.绑定事件
    69     closeBanner.onclick = function () {
    70         //3.书写事件驱动程序
    71 //        console.log(1);
    72         //类控制
    73 //        topBanner.className += " hide"; //保留原类名,添加新类名
    74         topBanner.className = "hide";//替换旧类名
    75 //        topBanner.style.display = "none";
    76     }
    77 
    78 </script>
    79 </body>
    80 </html>
  • 相关阅读:
    codeforces B. Strongly Connected City(dfs水过)
    codeforces A. Bayan Bus(简单模拟)
    AC_Dream 1211 Reactor Cooling
    AC_Dream 1224 Robbers(贪心)
    java中DatagramSocket连续发送多个数据报包时产生丢包现象解决方案
    AC_Dream 1216 G
    java模拟一个简单的QQ
    codeforces D. Design Tutorial: Inverse the Problem
    codeforces B. Design Tutorial: Learn from Life
    codeforce A. Design Tutorial: Learn from Math
  • 原文地址:https://www.cnblogs.com/BingBing-Deng/p/10427006.html
Copyright © 2011-2022 走看看