This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

images

Summary

Legacy method. Use document.querySelectorAll(“img”) instead. Gets a live collection of img elements in a document.

Property of dom/Documentdom/Document

Syntax

Note: This property is read-only.

var imageCollection = document.images;

Return Value

Returns an object of type

A live collection of img elements in the document.

Examples

Logging the source URL of the first image in the document using the legacy property.

// Caching the collection,
// instead of looking up the images property every time.
// Alternatively and more efficiently,
// use document.querySelectorAll("img") here instead.
var imageList = document.images;
// Verifying the collection is not empty.
if (imageList.length) {
  console.log(
    "The source URL of the first image in the document is - " +
    // Getting the src property of the first item in the collection.
    imageList[0].src);
}

Usage

 This is a legacy property. Use document.querySelectorAll("img") instead, which returns a static list instead.

Use this property to get a live collection of img elements in a document.

Notes

Since this property returns a live collection, there are performance implications.

Related specifications

WHATWG HTML
Living Standard
HTML5
Last Call Working Draft

Attributions