Warning: mkdir(): No space left on device in /www/wwwroot/test001/func.php on line 253

Warning: file_put_contents(./cachefile_yuan/hillsideartistshouse.com/cache/3b/51d17/29335.html): failed to open stream: No such file or directory in /www/wwwroot/test001/func.php on line 241
網頁中node和element是什麽關係,如何看待dom操作?_網站建設_網站製作_做網站的公司_999元全包_漢獅網絡
  • 百姓彩票

    先設計 後付費,服務更有保障

    2024我們與您攜手共贏,為您的企業形象保駕護航!

    網頁中node和element是什麽關係,如何看待dom操作?

    node即:節點,element即:元素。簡單的說就是Node是一個基類,DOM中的Element,Text和Comment都繼承於它。 換句話說,Element,Text和Comment是三種特殊的Node,它們分別叫做ELEMENT_NODE, TEXT_NODE和COMMENT_NODE。所以我們平時使用的html上的元素,即Element,是類型為ELEMENT_NODE的Node。

    <body>
        we can put text here 1...                      text_node
        <h1>China</h1>                                 element_node
        we can put text here 2...                      text_node
        <!-- My comment ...  -->                       comment_node
        we can put text here 3...                      text_node
        <p>China is a popular country with...</p>      element_node
        we can put text here 4...                      text_node
        <div>
          <button>See details</button>                 element_node
        </div>
        we can put text here 5 ...                     text_node
    </body>

    NodeList vs HTMLCollection:
    我們用childNodes找到了NodeList,但我們操作DOM時往往不想操作Node(我隻想操作元素Element),那麽如何獲取ElementList呢?
    其實我們經常使用的getElementsByXXX返回的就是一個ElementList,隻不過它的真實名字是ElementCollection。就像NodeList是Node的集合一樣,ElementCollection也是Element的集合。但需要特別注意的是:NodeList和ElementCollcetion都不是真正的數組,如果document.getElementsByTagName('a') instanceof Array,那麽必然是false。

    DOM(Document Object Model)簡稱文檔對象模型,它是html和xml是文檔編程的接口,它將文檔解析為樹結構,這個樹的根部就是document,而document的第一個子節點(childeNodes[0])就是html,這才有了後麵的一係列html元素。


    我漢獅網絡提供網站建設、APP軟件開發、軟件開發、小程序開發、網站網絡營銷等一站式服務,歡迎企業谘詢
    免費谘詢:18838171308

    先設計 後付費,服務更有保障

    2024我們與您攜手共贏,為您的企業形象保駕護航!

    在線客服
    聯係方式

    24h谘詢電話

    18838171308

    微信二維碼
    微信