关注点一:

  display:none;一旦用于某个元素,那个这个元素在页面中就不再占据位置。

  visibility:hidden;用于某个元素时,这个元素还会占据位置。

 

关注点二:

  即使使用了display:none;只是在dom树中其不再显示了,但是,文件中还有这个元素(废话!)。  

 

关注点三:

   我们知道一旦某一个元素拥有id特性,那么这个id名就会成为全局变量被调用,值得注意的是,这个id只能有一个! 如果一个页面中有两个id,那么我们直接使用id名称并关联事件时,将不再生效(这时可以根据控制台的地址此时的button为undefined)。如下:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF8">
    <title>获取验证码的倒计时</title>
    <style>
        .first_button{
            background-color: red;
        }
    </style>
</head>
<body>
    <button id="button" class="first_button">这是第一个</button>
    <button id="button">这是第二个</button>
    <script>
        button.onclick = function () {
            alert("d");
        }
    </script>
</body>
</html>
View Code

相关文章:

  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2021-12-24
猜你喜欢
  • 2022-12-23
  • 2021-06-27
  • 2021-11-08
  • 2021-07-10
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案