Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM images collection

HTML DOM images collection

Document Object Reference Document Object


Definition and Usage

The images collection returns an array of all images in the current document.

Syntax

document.images[]

.property


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the images collection


Example

Example 1

Returns the number of images in the document:

Number of images:

The example above produces the following output:

Number of images: 2

Try it »

Example 2

Returns the first image in the document:

ID of the first image:

The example above produces the following output:

ID of the first image: runoob1

Try it »


Document Object Reference Document Object