title: how to change image onclick javascript function?
body: <p>I got a problem, I tried several times but result is always same, I don't know what's wrong with my code. If you click on right image, it will change to left image, but if you click on left image, it wont change to right image, why?
  here is code:</p>
  
  <pre><code>    function changeImage() {
  
      if  (document.getElementById("changer").src == "imgs/left.gif")
      {
          document.getElementById("changer").src = "imgs/right.gif";
      }
      else 
      {
          document.getElementById("changer").src = "imgs/left.gif";
      }
  
  }
  </code></pre>
  
  <p>and image src code here:</p>
  
  <pre><code>&lt;img  src="imgs/right.gif" id="changer" onclick="changeImage()"/&gt;&lt;/a&gt;
  </code></pre>
  
  <p>I need this function: 
  click on (right arrow image), then it'll change to (left arrow image)  and click on same (left arrow image) again will return to default, (right arrow image). </p>
  
  <p>Thank you in advance for your time and help.</p>