title: JavaScript change the color of current element by clck
body: <p>i have a question about changing the color of only Current element. 
  So i want to change the background color of the current element by every click.</p>
  
  <p>My problem is, i can not reset the background color of previous element. </p>
  
  <p>For an example i have here  two background color(yellow, lightblue), if i click on "old div" and "new div", than the  background color of two divs changes to green. But only one div should be set to green. </p>
  
  <p>So by every click must change only the background color of current element.</p>
  
  <p>JavaScript</p>
  
  <pre><code>var divTag = document.getElementsByTagName("div");
  
  for (var i = 0; i &lt; divTag.length; i++) {
      if (divTag[i].tagName == "DIV" || divTag[i].tagName == "div") {
           if (divTag[i].addEventListener) {
              divTag[i].addEventListener('click', callback,false);
           } 
           else if (divTag[i].attachEvent) {
              divTag[i].attachEvent('on' + 'click',callback);
           }
      }
  }
  
  function callback(e) {
      e = e || window.event;
      var target = e.target || e.srcElement;
      target.style.backgroundColor = "green";
      e.stopPropagation();
  }
  </code></pre>
  
  <p>HTML </p>
  
  <pre><code>&lt;div id="old"&gt;
      &lt;input style="margin: 10px;" type="textbox" /&gt;
      &lt;div id="new"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>CSS</p>
  
  <pre><code>#old {
      width:200px;
      height:200px;
      background-color:yellow;
  }
  #new{
      width:20px;
      height:20px;
      background-color:lightblue;
  }
  </code></pre>
  
  <p>Can you help me? 
  Thanks in advance</p>