JavaScript Reference/Javascript Collections/images

Материал из Web эксперт
Перейти к: навигация, поиск

"images" Example

   <source lang="javascript">
   

<html> <body> <img src="image1.jpg" width="100" height="100"> <img src="image2.jpg" width="100" height="100"> <img src="image3.jpg" width="100" height="100"> <img src="image1.jpg" width="100" height="100"> <img src="image2.jpg" width="100" height="100"> <img src="image3.jpg" width="100" height="100"> <button onclick="alert(document.images.length);"> Number of images in the document </button> </body> </html>


     </source>
   
  


"images" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |document | +----------------+--------------------------------------------------------------+

     </source>
   
  


"images" JavaScript properties and JavaScript methods

   <source lang="javascript">

JavaScript properties and JavaScript methods

item(), length, namedItem(), tags(), urns()


     </source>
   
  


"images" Syntax Parameters and Note

   <source lang="javascript">

Note: Returns an array of all <img> elements in the document.

Syntax:

document.images // returns all images document.images(param1, param2) // returns an individual image

   param1   Required; zero-based index or 
                      the value of the desired member"s id or name attribute.
   param2   Optional; zero-based index for the result returned
                      if param1 matches more than one element.
   
     
     </source>