zoukankan      html  css  js  c++  java
  • NodeList和HTMLCollection区别

    关于DOM集合接口,主要不同在于HTMLCollection是元素集合而NodeList是节点集合(既包括元素,也包括节点)。

    规定一下结果是:

    1. node.childNodes 结果返回类型是 NodeList,
    2. node.children 结果返回类型是 HTMLCollection 
    3. node(document或者其他不同节点).getElementsByXXX 结果返回类型是HTMLCollection

    唯一要注意的是 querySelectorAll 返回的是 NodeList ,但是实际上是元素集合,并且是静态的,

    其他接口返回的HTMLCollection和NodeList都是动态的,即取得的结果会随着相应元素的增减而增减。

    PS:《JS权威指南第六版》关于getElementByName() 和 getElementsByTagName() 都返回 NodeList 对象,是不对的,

    规定都返回 HTMLCollection对象。

  • 相关阅读:
    python之道04
    python之list [ 列表 ]
    end和sep的使用方法
    pass1
    python之for (循环)
    python之range (范围)
    python之str (字符型)
    python之bool (布尔值)
    python之int (整型)
    python之道03
  • 原文地址:https://www.cnblogs.com/liutie1030/p/5657276.html
Copyright © 2011-2022 走看看