Document.images

  • Revision slug: DOM/document.images
  • Revision title: document.images
  • Revision id: 29864
  • Created:
  • Creator: Yanmorin
  • Is current revision? No
  • Comment 4 words added, 1 words removed

Revision Content

{{ DomRef() }}

Summary

document.images returns a collection of the images in the current HTML document.

Syntax

var htmlCollection = document.images;

Example

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.

Specification

DOM Level 2 HTML: HTMLDocument.images

{{ languages( { "fr": "fr/DOM/document.images", "pl": "pl/DOM/document.images" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<h3 name="Summary">Summary</h3>
<p><code>document.images</code> returns a collection of the <a href="/en/DOM/Image" title="en/DOM/Image">images</a> in the current HTML document.</p>
<h3 name="Syntax">Syntax</h3>
<pre class="eval"><em>var htmlCollection</em> = document.images;
</pre>
<h3 name="Example">Example</h3>
<pre class="eval">var ilist = document.images;
for(var i = 0; i &lt; ilist.length; i++) {
    if(ilist[i].src == "banner.gif") {
         // found the banner
    }
}

</pre>
<h3 name="Notes">Notes</h3>
<p><code>document.images.length</code> – property, returns the number of images on the page.</p>
<p><code>document.images</code> is part of DOM HTML, and it only works for HTML documents.</p>
<h3 name="Specification">Specification</h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-90379117">DOM Level 2 HTML: HTMLDocument.images</a></p>
<p>{{ languages( { "fr": "fr/DOM/document.images", "pl": "pl/DOM/document.images" } ) }}</p>
Revert to this revision