title: jQuery looping prev next
body: <p>I found <a href="http://jsfiddle.net/p88Kz/" rel="nofollow">this bit of code</a> whist searching for a basic slider and its near enough does what I want but I would like it to loop once it got to the last li, i.e if last li and next button is clicked loop to 1st and continue, </p>
  
  <p>all help is appreciated and as always thanks in advance.</p>
  
  <pre><code>$('.udtalelse').addClass("passiv");
  ctrlKunder(0);
  
  $('#prev').click(function() {
      var index = getActive();
      if (index == 0) return;
      index--;
      ctrlKunder(index);
  })
  $('#next').click(function() {
      var index = getActive();
      if (index == $('.udtalelse').length - 1) return;
      index++;
      ctrlKunder(index);
  })
  
  function ctrlKunder(ele) {
      $('.udtalelse').removeClass("active").addClass("passiv");
      $('.udtalelse').eq(ele).removeClass("passiv").addClass("active");
  }
  
  function getActive() {
      var index;
      $('.udtalelse').each(function(i) {
          if ($(this).hasClass("active")) index = i;
      })
      return index;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;ul class="kunder"&gt;
      &lt;li&gt;&lt;span class="udtalelse"&gt;Indhold 1&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;&lt;span class="udtalelse"&gt;Indhold 2&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;&lt;span class="udtalelse"&gt;Indhold 3&lt;/span&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;span class="kunderpagination"&gt;
      &lt;a href="#" id="prev"&gt;« Previous&lt;/a&gt; |
      &lt;a href="#" id="next"&gt;Next »&lt;/a&gt;
  &lt;/span&gt;
  </code></pre>