JS Trying to give a select effect to a tag
<p>I'm trying to apply a 'select like' effect with JS, my function is triggered
on onClick event<br> and it change the tag style, but the tag style remains unchanged after selected a new tag,<br> the main idea of the first block of code is reset to the default style the old selections, but doesn't work..</p>

<pre><code>function selectEffect(tag){
  //Code to reset to the default style first if something is selected
  var headID = document.getElementsByTagName("head")[0];         
  var cssNode = document.createElement('link');
  cssNode.type = 'text/css';
  cssNode.rel = 'stylesheet';
  cssNode.href = '../static/css/style.css';
  cssNode.media = 'screen';
  headID.appendChild(cssNode);

  //Code to apply a selected like style
  var element = document.getElementById(tag);
  element.style.backgroundColor='#7D9ABE';
  element.style.color='#ffffff';
  element.style.fontWeight='bold';
  }
</code></pre>

<p>What's wrong with it?, Any help is appreciated..
Thanks.</p>
