title: Alternate content of a div every 3 seconds with javascript
body: <p>I would like to alternate the contents of a div (or swap in a new div if better) every few seconds, with a fade in/out. Jquery prefered, or pure js fine too.</p>
  
  <p>Based on Arun's solution, I have added the Jquery below, and it works perfectly... but <strong>how do I make it repeat?</strong></p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="wrapper" style="height:100px"&gt;
    &lt;div id="quote1"&gt;I am a quote&lt;/div&gt;
    &lt;div id="quote2"&gt;I am another quote&lt;/div&gt;
    &lt;div id="quote3"&gt;I am yet another quote&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Javascript: (as per Arun in the comments)</p>
  
  <pre><code>jQuery(function () {
      var $els = $('div[id^=quote]'),
          i = 0,
          len = $els.length;
  
      $els.slice(1).hide();
      setInterval(function () {
          $els.eq(i).fadeOut(function () {
              $els.eq(++i % len).fadeIn();
          })
      }, 2500)
  })
  </code></pre>