I tried something like this:
document.getElementById("spanID").setAttribute("class", "testClass");
Works in Firefox, but does not work in IE (both 6 and 7). Anyone know of any workaround?
| SitePoint Sponsor |
I tried something like this:
document.getElementById("spanID").setAttribute("class", "testClass");
Works in Firefox, but does not work in IE (both 6 and 7). Anyone know of any workaround?
Use className instead of setAttribute().
Code:document.getElementById("spanID").className = "testClass";
We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.
Thanks a lot Kravvitz, works perfect.
for class to be set with setAttribute in IE you have to use className:
the same is for "for" in lable elementsCode:elm.setAttribute('className', 'class');
IE problem onlyCode:elm.setAttribute('htmlFor', 'for');
Bookmarks