[Javascript] Changing the CSS class of an element

Peter Brunone peter at brunone.com
Tue May 18 09:27:26 CDT 2004


Hi Terry,

   I'm not sure if this holds true for all other browsers (you can find out pretty quickly by trying it), but in IE, the syntax would be

document.getElementById('mytablecell').className = "myNewClass"

Cheers,

Peter


Original Message:
>From: Terry Riegel <riegel at clearimageonline.com>

>Is there a way to change the class of an element
>
>For example:
>
>I would like to change
><td class="blue" id="mytablecell">
>to
><td class="green" id="mytablecell">
>
>currently I am doing something like this.
>
>document.getElementById('mytablecell').style.backgroundColor = 
>'#ffffff';
>
>I would prefer to change the whole style if I can then I can change a 
>lot of things at once.
>
>
>Terry Riegel
>-----------------
>MAILKEY: 2524427349





More information about the Javascript mailing list