SYNCERのロゴ
アイキャッチ画像

Document.images - img要素

imagesは、Documentのプロパティです。ドキュメントの全てのimg要素を返します。

概要

名前
images
所属
Document
IDL
[SameObject] readonly attribute HTMLCollection images;
仕様書
https://html.spec.whatwg.org/multipage/dom.html#dom-document-images

説明

全てのimg要素をHTMLCollectionで返す。読み取り専用なので、値を代入して変更することはできない。

チュートリアル

Document.imagesを利用して、img要素を取得する例です。

<img src="./image1.png">
<img src="./image2.png">
<img src="./image3.png">
var images = document.images ;

images[0] ;	// <img src="./image1.png">
images[1] ;	// <img src="./image2.png">
images[2] ;	// <img src="./image3.png">

Document.getElementsByTagName()と同じです。

var images = document.images ;

var images = document.getElementsByTagName( "img" ) ;

デモ

Document.imagesのデモです。

<!-- このコードは編集できます。 -->

<!DOCTYPE html>
<html>
<body>
<img src="./image1.png" width="120" height="120">
<img src="./image2.png" width="120" height="120">
<img src="./image3.png" width="120" height="120">
<hr>
<script>
var value = document.images ;

console.log( value ) ;
document.body.appendChild( new Text( value ) ) ;
</script>
</body>
</html>

サポート状況

ChromeFirefoxSafariEdgeIEOperaiOS SafariAndroid
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年10月6日 (金)
コンテンツを公開しました。