I have a Web page that runs properly with IE 9 with the following code:
// Check for IE
if (isBrowserIE) tempArray[i].setAttribute("className", "red");
else tempArray[i].setAttribute("class", "red");
I have now created a new (separate) page that uses the SAME code--I did a copy and paste of the whole function containing this code from the page that works into the new page. However, the function (this if-statement in particular) does not work in the new page--the new page does NOT make the array item red, BUT it does make it red if I change "className" to "class"--just as if IE now uses "class" like everyone else. But then the older page that still has "className" should not work, but it does!
This would seem to be an impossible scenario. Any ideas?
(1) Your more concise code did work, and since it is more concise and direct, I'll probably switch to it. However, my code also worked in IE 9 by simply using "class" rather than "className" in the code segment posted.
(2) My real question was why my original code worked in IE 9 on one page but did not work on another page on which the whole function containing that code was copy and pasted. The code I posted was identical on the two pages. One page worked (turned the text red) and the other page did not. I was hoping to find an explanation for THAT! As I said in my original post, that would seem to be impossible.