Document.images
document.images
returns a collection of the images in the current HTML document.
Syntax
JavaScript
Copy Code
var htmlCollection = document.images;
Example
JavaScript
Copy Code
var ilist = document.images; for(var i = 0; i < ilist.length; i++) { if(ilist[i].src == "banner.gif") { // found the banner } }
Notes
document.images.length
– property, returns the number of images on the page.
document.images
is part of DOM HTML, and it only works for HTML documents.
Specifications
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'Document.images' in that specification. |
Living Standard | |
Document Object Model (DOM) Level 2 HTML Specification The definition of 'Document.images' in that specification. |
Recommendation | Initial definition. |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/document/images