Assigning a whole style class with javascript

J

jebe

Hi all,

I just struggling with the follwing problem: I have defined a style
class
..myClass {
color: ....
font-weight: ...
margin:...
...
}

and by using JavaScript I now want to assign the whole class to an HTML
element (a table cell).
The only topics I found were about how to assign a style attribute
(like color:
document.forms['myform'].elements[myElement].style.color = '#FF0000';
)

I have tried a lot but did not get the right syntax to assign my whole
style class "myClass" instead of just the attribute.

Isn't it possible or how is the correct syntax?

Thanks in advance
John
 
F

frizzle

document.forms['myform'].elements[myElement].className = 'myClass';

you're welcome ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top