title: Pure javascript image gallery with fwd and bck function
body: <p>Hi I know it is a partly duplicate question but i had no other option as other questions cover it only partly <a href="https://stackoverflow.com/questions/14299917/making-a-simple-javascript-image-gallery">Making a simple javascript Image gallery</a>. Actually I made this js image gallery code but it not working. Can anyone please help explain what's going on.</p>
  
  <h2>JAVASCRIPT</h2>
  
  <pre><code>var imageGallery = new Array();
  imageGallery[0] = '2.png';
  imageGallery[1] = '3.png';
  imageGallery[2] = '4.png';
  imageGallery[3] = '5.png';
  imageGallery[4] = '6.png';
  var imgCount = 0;
  function next() {
      imgCount++ ;
      document.getElementById("gallery").style.background = 'url(' + imageGallery[imgCount] + ')';
  }
  
  function previous() {
      imgCount--;
      document.getElementById("gallery").style.background = 'url(' + imageGallery[imgCount] + ')';    
      }   
  </code></pre>
  
  <h2>HTML</h2>
  
  <pre><code>&lt;a href onclick="next(); return = false;"&gt;Next&lt;/a&gt;
  &lt;a href onclick="previous(); return = false;"&gt;Back&lt;/a&gt;
  &lt;div id="gallery" style="background: url(1.png); height:420px; width:744px"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>TBN: This is not the final code as next and previous buttons keep on executing as long as they are pressed.</p>