title: jQuery infinite loop through each div
body: <p>I have some divs with divs in them, which I want to loop through while removing a class from the current one, then adding a class to the next one.</p>
  
  <p>Then when I reach the last one, I want to go back to the start and do it all over again.</p>
  
  <p>I already have a way of doing this, but it only works for one set of divs, I'm going to be having many sets of divs that need to loop independently.</p>
  
  <p>Here's an example few sets (there would be a random amount of divs in each):</p>
  
  <pre><code>&lt;div class="set"&gt;
      &lt;div class="current"&gt;Item1&lt;/div&gt;
      &lt;div&gt;Item2&lt;/div&gt;
      &lt;div&gt;Item3&lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;div class="set"&gt;
      &lt;div class="current"&gt;Item1&lt;/div&gt;
      &lt;div&gt;Item2&lt;/div&gt;
      &lt;div&gt;Item3&lt;/div&gt;
      &lt;div&gt;Item4&lt;/div&gt;
      &lt;div&gt;Item5&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I need to remove that current class, and add it to the next div in each set, and so on.</p>
  
  <p>Here is the code I have that works with one set:</p>
  
  <pre><code>$(function() {
      var items = $('.set div').length;
          current = 0;
  
      setInterval(function() {
          $('.set div').eq(current).removeClass('current');
  
          if (current == items - 1){
              current = 0;
          } else {
              current++;
          }
  
          $('.set div').eq(current).addClass('current');
      }, 500);
  });
  </code></pre>