JavaScript » Document » images

Syntax:
document.images["imageID"]

This property is an array containing references to all the Image objects in the current document.

This property is an array containing references to all the Image objects in the current document. These references are stored in the array in the order in which they are defined in the source code. The "imageID" argument is used to access items in the array and this can either be a string containing the image name as defined within the <IMG> tag in the HTML source, or an integer (with '0' being the first item in the array).

Examples

Code:
document.images["imagename1"]
document.images["imagename2"]
document.images["imagename3"]

document.images[0]
document.images[1]
document.images[2]
Explanation:

Both examples return the same results; the first uses the defined names of the images and the second uses their reference number within the array.