title: How to make jQuery each loop repeat infinite number of times
body: <p>I am trying to create a slideshow and repeat an <code>each</code> loop once it has cycled through each image. I have tried everything but cannot get the loop to continue after it has cycled through each image. Please see my code and attempt below.</p>
  
  <p>Anyone have any ideas? Have tried everything.</p>
  
  <p><strong>html</strong></p>
  
  <pre><code>&lt;img src="http://elegantthemes.com/preview/InStyle/wp-content/uploads/2008/11/s-1.jpg" /&gt;
  &lt;img src="http://elegantthemes.com/preview/InStyle/wp-content/uploads/2008/11/s-5.jpg" /&gt;
  &lt;img src="http://elegantthemes.com/preview/InStyle/wp-content/uploads/2008/11/s-3.jpg" /&gt;
  </code></pre>
  
  <p><strong>js</strong></p>
  
  <pre><code>function test() {
      $("img").each(function(index) {
          $(this).hide();
          $(this).delay(3000 * index).fadeIn(3000).fadeOut();
      });
  
     if(index === 3){
        index = 0;
     }
  }
  test();
  </code></pre>