NamedNodeMap.item()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
item()
は NamedNodeMap
インターフェイスのメソッドで、マップ内の指定された位置にある項目を返します。
メモ:
このメソッドは、 []
演算子の構文を使用した場合にも呼び出されます。
そのため i
が数値の場合、 myMap[i]
は myMap.item(i)
と同じです。
構文
js
item(index);
[index];
引数
index
-
返したい項目の位置を表す数値です。
返値
Attr
です。数値がマップの length
以上の場合は null
です。
例
html
<pre zero="test" one="test" two="test"></pre>
js
const pre = document.getElementsByTagName("pre")[0];
const attrMap = pre.attributes;
pre.textContent = `The attribute map contains:
0: ${attrMap.item(0).name}
1: ${attrMap[1].name}
2: ${attrMap.item(2).name}`;
仕様書
Specification |
---|
DOM # dom-namednodemap-item |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
item |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.