changing css properties via javascript

Posted by tic on Stack Overflow See other posts from Stack Overflow or by tic
Published on 2010-03-14T10:18:38Z Indexed on 2010/03/14 10:25 UTC
Read the original article Hit count: 244

Filed under:
|
|

I need a function to change the appearance of some elements in my html page "on the fly", but I am not able to do. The problem is that I cannot use a command like

document.write ('body {background-color: #cccccc;}');

because I need to make the changes effective when the page is already loaded, using a link like

<a onmouseclick="Clicker(1)" href="#">clic</a>

and I cannot use a command like

document.body.style.background='#cccccc';

because I do not know if it can be applied to other not so easy cases, because I need to change the appearance of elements such as td.myclass or sibling elements such as th[scope=col]+th[scope=col]+th[scope=col].

How can I do it? Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css