NamedNodeMap: length 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

NamedNodeMap 接口的只读 length 属性表示映射中存储的对象的数量。

一个数字,包含映射中对象的数量

示例

html
<pre class="foo" id="bar" contenteditable></pre>
js
const pre = document.querySelector("pre");
const attrMap = pre.attributes;
pre.textContent = `The 'test' attribute contains ${attrMap.length} attributes.\n`;

规范

规范
DOM
# dom-namednodemap-length

浏览器兼容性