After creating an array with document.getElementsByClassName()
, I want to change the className
property of each element. Individual elements can be accessed properly by using literal subscripts. However, when using a for loop, such as:
for (i = 0; i < myElements.length; i += 1) { ... }
I'm getting only alternate elements, which seems to defy what the for
loop is doing. And after the for
executes the processed elements are no longer in the array, which is also unintended.
I have loaded a test page at http://www.mwpnz.com/classes/page.htm (This include extensive debug code to see what is happening) Thank you.