节点概述

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

  <body>
    <div>我是div</div>

    <span>我是span</span>

    <ul>
      <li>我是li</li>
      <li>我是li</li>
      <li>我是li</li>
      <li>我是li</li>
    </ul>

    <div class="box">
      <span class="erweima">×</span>
    </div>

    <script>
      // 一个节点,  至少拥有:
      // nodeType  节点类型
      // nodeName  节点名称
      // nodeValue 节点值
      var box = document.querySelector(".box");
      console.dir(box);
      //  nodeName: "DIV"
      //  nodeType: 1    (1 => 元素节点, 2 => 属性节点, 3 => 文本节点)
      //  nodeValue: null
    </script>
  </body>
</html>