I want to iterate over some DOM elements, I\'m doing this:
document.getElementsByClassName( \"myclass\" ).forEach( function(element, index, array) {
//do s
Edit: Although the return type has changed in new versions of HTML (see Tim Down's updated answer), the code below still works.
As others have said, it's a NodeList. Here's a complete, working example you can try:
getElementsByClassName Test
This is an odd para.
This is an even para.
This one is also odd.
This one is not odd.
This works in IE 9, FF 5, Safari 5, and Chrome 12 on Win 7.