Ele.attrbutes将返回一个NamedNodeMap对象,即NamedNodeMap存储的是元素的“特性Attribute”集合。而集合中的每一个元素,都是Attr类型的对象。

html:

    <ul id="box" data-url="index.html" node-action="submit">
      <li>节点一</li>
      <li>节点二</li>
      <li>节点三</li>
    </ul>

JS:

    var box = document.getElementById("box");
    var attrs = box.attributes;
    console.log(attrs);
    console.log(attrs.length);
    console.log(attrs[0]);
    console.log(attrs.item(1));

结果如下:

(三)类数组对象 NamedNodeMap简单介绍

 

相关文章:

  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-12-06
  • 2021-10-17
猜你喜欢
  • 2022-12-23
  • 2021-06-22
  • 2021-11-17
  • 2021-11-20
  • 2022-01-12
  • 2021-07-06
  • 2021-09-09
相关资源
相似解决方案