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.
値
現在の文書内に掲載されているすべての画像の生きたリストを提供する 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 GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
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.
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.