Click to See Complete Forum and Search --> : How can I use javascript to change an object's CSS class ?


Chanie
06-19-2003, 10:21 AM
How can I use javascript to change an object's CSS class ?
i.e. how to call the object's class property.
Is that something like this :
document.table.td['3'].class = css_stype1;
I would like to know the exactly calling syntax.
Is there any webpage or reference shows a list of all html objects's calling syntax ?

Khalid Ali
06-19-2003, 10:25 AM
object.className = classname

for the DOM compliance browsers I'd prefer this method,though,I have noticed it doesn't work with IE..

object.setAttribute("CLASS",classname);

jovialjonny
06-19-2003, 10:25 AM
however you reference the object just put .className after it NOT .class like you have above i.e.:
document.table.td['3'].className = css_stype1;