title: Change Image on click (6 Image Loop)
body: <p>I have 6 images that I want to swap between by clicking on the image but I can't seem to get the code right in order to make it go to the next picture</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>    &lt;img src="BCover.jpg" id="ImgGallery" onclick="ImgGallery()"/&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>var counter = 1;
  
  ImgGallery.onclick = function (){
  if (counter == 1){
      document.getElementById("ImgGallery").src = "BCover.jpg";
      counter++;
  }
  else if (counter == 2){
      document.getElementById("ImgGallery").src = "MechGP.jpg";
      counter++;
  }
  else if (counter == 3){
      document.getElementById("ImgGallery").src = "Mech2.jpg";
      counter++;
  }
  else if (counter == 4){
      document.getElementById("ImgGallery").src = "Mech3.jpg";
      counter++;
  }
  else if (counter == 5){
      document.getElementById("ImgGallery").src = "Mech4.jpg";
      counter++;
  }
  else if (counter == 6){
      document.getElementById("ImgGallery").src = "MCA1.png";
      counter==1;
  }
  };
  </code></pre>