title: Changing icon multiple times using onclick using javascript similar to gmail star icon
body: <p>I have an icon image which changes into another image by this code</p>
  
  <pre><code>&lt;html&gt;
  &lt;script&gt;
  
  function changeImg(thisImg) {
    if(prevImg) {
      prevImg.src=prevSrc;
    }  
    prevImg = thisImg;
    prevSrc = thisImg.src;
    thisImg.src = "flag_green.gif";
  }
  &lt;/script&gt;
  &lt;body&gt;
  &lt;img alt="" src="flag_blue.gif" id="imgClickAndChange" onclick="changeImg(this)"  /&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>But I am unable to change it back to the previous image again after clicking the original image . please help. I want it similar like the gmail important star icon feature</p>