A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/API/HTMLCollection/item below:

HTMLCollection: item() メソッド - Web API

HTMLCollection: item() メソッド

Baseline Widely available

HTMLCollection の item() メソッドは、この集合の中で指定された位置にあるノードを返します。

メモ: HTMLCollection の中身はライブであるため、その背景にある DOM が変化すると、子の集合内にある個々のノードの位置は変化する可能性があり、インデックス値が指定されたノードを差し続けなくなる可能性があります。

構文 引数
index

返す Node の位置。要素は HTMLCollection 内で、文書内のソースに現れる順序と同じ順序で現れます。

返値

指定したインデックスにある Node、または index が 0 より小さいか length プロパティ以上の場合は null です。

使用上の注意

item() メソッドは HTMLCollection から番号付けされた要素を返します。JavaScript で HTMLCollection を配列として扱い、配列記法を使用してインデックスを作成する方が簡単です。下記の例を参照してください。

例
const images = document.images; // これは HTMLCollection
const img0 = images.item(0); // このように item() メソッドを使うことができる
const img1 = images[1]; // ただし、この記述方がより易しく一般的
ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4