Skip to content Skip to sidebar Skip to footer

How To Find All Elements In A Page

I know of two ways to find all the elements in the page. document.getElementsByTagName('*') and document.all Is there a better way or is one of these the best? I'm making an elemen

Solution 1:

document.all is an outdated proprietary method from Microsoft. Don't use it.

document.getElementsByTagName('*') is the W3C standard method of finding all the elements ina document - and surely the fastest - and works in Internet Explorer as well.

P.S. As someone is bound to chime in and provide a jQuery answer to this question, there's how to select all elements in a page using jQuery: jQuery('*');

:-)


Post a Comment for "How To Find All Elements In A Page"