在Chrome控制台document.getElementByClassName中返回额外的信息

时间:2019-08-18 13:56:45

标签: javascript html dom web-deployment

在chrome控制台中,使用document.getElementByClassName时,它将返回一个数组。

但是当我扩展数组时,数组的每个元素都显示了附加细节,这些细节是什么,以及当我打印单个元素时为什么它们不出现。

HTMLCollection(5) [div.example, div.example, p.example, span.example, button.example]
0: div.example
accessKey: ""
align: ""
assignedSlot: null
attributeStyleMap: StylePropertyMap {size: 1}
attributes: NamedNodeMap {0: class, 1: style, class: class, style: style, length: 2}
autocapitalize: ""

1 个答案:

答案 0 :(得分:0)

  

它们是什么?

Element的属性。

  

当我打印单个元素时为什么它们不出现

元素的默认log(至少在Chrome中是Node元素本身)。 console.dir将与getElementByClassName打印相同。