Entry
Can I change the class style assigned to an element?
Can I change the style class assigned to an element?
May 27th, 2000 07:28
Rey Nuņez, Steve Claflin, http://www.w3.org/TR/DOM-Level-2/html.html#ID-95362176
Yes, styles can be cascaded. This is basically accomplished by defining
two (or more) classes in an embedded or linked style sheet, then
applying the appropriate style class to the element, for example, on an
onmouseover event.
<span onmouseover="this.className='newclass'"
onmouseout="this.className='oldclass'">Hello</span>
The DOM Level 2 specifies the usage of "className" for CSS classes in
scripting, to avoid language conflicts with other platforms, like Java.
Note however that this is currently supported only in IE4+. Though NS6
supposedly supports this, it can only do one change, meaning you can't
revert to the previous class after the change.