获取特殊元素

Tutorial: DOM操作 Category: JS Published: 2026-04-07 13:58:26 Views: 22 Likes: 0 Comments: 0
<!DOCTYPE html>
<html lang="en">
  <head></head>

  <body>
    <script>
      // 1.获取body 元素
      var bodyEle = document.body;
      console.log(1, bodyEle);
      console.dir(bodyEle);

      // 2.获取html 元素
      var htmlEle = document.documentElement;
      console.log(2, htmlEle);
    </script>
  </body>
</html>