title: Changing CSS properties via JavaScript
body: <p>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 it.</p>
  
  <p>The problem is that I cannot use a command like</p>
  
  <pre><code>document.write ('&lt;style type="text/css"&gt;body {background-color: #cccccc;}&lt;/style&gt;');
  </code></pre>
  
  <p>because I need to make the changes effective when the page is already loaded, using a link like</p>
  
  <pre><code>&lt;a onmouseclick="Clicker(1)" href="#"&gt;clic&lt;/a&gt;
  </code></pre>
  
  <p>and I cannot use a command like</p>
  
  <pre><code>document.body.style.background = '#cccccc';
  </code></pre>
  
  <p>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 <code>td.myclass</code> or sibling elements such as <code>th[scope=col]+th[scope=col]+th[scope=col]</code>.</p>
  
  <p>How can I do it? Thanks!</p>