[Javascript] Listing Images on current page

Nick Fitzsimons nick at nickfitz.co.uk
Thu Sep 6 10:36:05 CDT 2007


> What is the difference between 
> document.getElementsByTagName("img") 
> and
> document.images
> 

document.images is of type HTMLCollection:
<http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-75
708506>
whereas the return value of document.getElementsByTagName() is of type
NodeList:
<http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core.html#ID-53
6297177>.

Both are live, so in practice there isn't much to choose between them; the
main difference is that the HTMLCollection supports the "item" and
"namedItem" methods, while the nodeList only supports "item".

Regards,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/




More information about the Javascript mailing list