Document: images プロパティ

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.

imagesDocument インターフェイスの読み取り専用プロパティで、現在の HTML 文書内の画像集合を返します。

現在の文書内に掲載されているすべての画像の生きたリストを提供する HTMLCollection 。 集合の各項目は、単一の画像要素を表す HTMLImageElement です。

使用メモ

返された集合において、集合内のアイテムにアクセスするには、JavaScript の配列記法か item() メソッドを使用することができます。 以下はのものは同等です。

js
firstImage = imageCollection.item(0);

firstImage = imageCollection[0];

この例では、画像のリストを見て、"banner.gif" という名前の画像を探します。

js
for (const image of document.images) {
  if (image.src === "banner.gif") {
    console.log("バナーを見つけました");
  }
}

仕様書

Specification
HTML
# dom-document-images-dev

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
images

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.