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

瀏覽器相容性