HTMLAllCollection: item() メソッド
item()
は HTMLAllCollection
インターフェイスのメソッドで、集合内の指定したオフセットに位置する要素、または id
属性または name
属性に指定した値を持つ要素を返します。
構文
js
item(nameOrIndex)
引数
nameOrIndex
-
この引数が整数、または整数に変換できる文字列の場合、
Element
を返す位置を表します。HTMLAllCollection
内に現れる要素は、文書内のソースに現れる順番と同じです。引数が文字列で整数に変換できない場合は、返す要素のname
またはid
として解釈されます。
返値
nameOrIndex
がインデックスを表す場合、item()
は指定したインデックスの Element
を返し、nameOrIndex
が 0 より小さいか length プロパティ以上の場合は null
を返します。nameOrIndex
が名前を表す場合、 item()
は namedItem()
と同じ値を返します。
ブラウザーの互換性
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.