title: javascript set element background color
body: <p>i have a little javascript function that does something when one clicks on the element having onclick that function.</p>
  
  <p>my problem is:
  i want that, into this function, to set a font color fot the html element having this function onclick. but i don't suceed. my code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function selecteazaElement(id,stock){
          document.addtobasket.idOfSelectedItem.value=id;
          var number23=document.addtobasket.number;
          number23.options.length=0;
          if (stock&gt;=6) stock=6;
  
          for (i=1;i&lt;=stock;i++){
              //alert ('id: '+id+'; stock: '+stock);
              number23.options[number23.options.length]=new Option(i, i);
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>and how i use it:</p>
  
  <pre><code>&lt;li id = "product_types"&gt;
      &lt;a href="#" onclick='selecteazaElement(&lt;?= $type-&gt;id; ?&gt;,&lt;?= $type-&gt;stock_2; ?&gt;);'&gt;&lt;?= $type-&gt;label; ?&gt;&lt;/a&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>any suggestions? thanks!</p>
  
  <p>i have added another function (jquery one) that does partially what i need. the new problem is: i want that background color to be set only on the last clicked item, not on all items that i click. code above:  </p>
  
  <pre><code>$(document).ready(function() {
      $('.product_types &gt; li').click(function() {
      $(this)
          .css('background-color','#EE178C')
          .siblings()
          .css('background-color','#ffffff');
      });
  });
  </code></pre>
  
  <p>any ideas why?</p>
  
  <p>thanks!</p>