title: jQuery loop image fadeout/in with time interval
body: <p>I have a jQuery function to fadeIn/Out images in a div. But when the function reaches last image, it gets stopped. Any way to get it in a loop, so that at the end of last image, it will start again from the first image.
  here is the code</p>
  
  <p>HTML:</p>
  
  <pre><code>   &lt;div id="homeimg"&gt;
          &lt;img src="image1.jpg" /&gt;
          &lt;img src="image2.jpg" /&gt;
          &lt;img src="image3.jpg" /&gt;
          &lt;img src="image4.jpg" /&gt;
     &lt;/div&gt;
  </code></pre>
  
  <p>jQuery:</p>
  
  <pre><code>   $(document).ready(function(){
        $('#homeimg img:first-child').addClass('activeimg');
        setInterval('cycleMe()', 4000);
     });
  
     function cycleMe() {
       $('.activeimg').next().css('z-index', 10);
       $('.activeimg').next().fadeIn(1500);
       $('.activeimg').fadeOut(1500, function(){
           $(this).next().fadeIn(0);
           $(this).next().addClass('activeimg');
           $(this).css('z-index', 5).removeClass('activeimg');
       });
      }
  </code></pre>
  
  <p>Any possibilities? Thanks in advance.</p>