English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
imagesA read-only attribute that returns the embedded<IMG>List of elements.
The elements in the list are sorted in the order they appear in the source code.
document.images
var x = document.images.length;Test and see‹/›
All browsers fully support the images attribute:
Attribute | |||||
images | Is | Is | Is | Is | Is |
Attribute | Description |
---|---|
length | Returns in the list<img>Number of elements |
Method | Description |
---|---|
[index] | Returns the specific node at the given index starting from zero in the list. If the index number is out of range, it returns null. |
item(index) | Returns the specific node at the given index starting from zero in the list. If the index number is out of range, it returns null. |
namedItem(id) | Returns a specific node whose ID name matches the string specified by name. If the id does not exist, it returns null. |
Return Value: | OneHTMLCollectionProvides a live list of all images contained within the current file. |
---|---|
DOM Version: | DOM Level1 |
This example browses through an image list and finds an image named "flower.jpg":
var imgList = document.images; for (let i = 0; i < imgList.length; i++) { if (imgList[i].src.endsWith("flower.jpg")) { // found the flower } }Test and see‹/›