PDA

View Full Version : IE not applying styles to dynamically created class


binaryWeapon
05-17-2009, 11:02 PM
When I add a class to an element with elem.setAttribute("class","foo"), IE isn't applying the style rules I have set in my stylesheet for the foo class. Is there any way around this?

adios
05-17-2009, 11:43 PM
http://www.digitalmediaminute.com/article/1394/the-browser-dom-and-the-class-attribute

Unless you're a glutton for punishment, I'd consider just assigning class directly, to the HTMLElement.className property.

lyllo
05-21-2009, 07:38 PM
When I add a class to an element with elem.setAttribute("class","foo"), IE isn't applying the style rules I have set in my stylesheet for the foo class. Is there any way around this?

use

elem.setAttribute("className","foo")