title: JQuery - Cycle a class with timer
body: <p>I've a list wit below structure</p>
  
  <pre><code>&lt;div id="slider"&gt;
    &lt;ul&gt;
      &lt;li class='active'&gt; a &lt;/li&gt;
      &lt;li&gt; b &lt;/li&gt;
      &lt;li&gt; c &lt;/li&gt;    
      &lt;li&gt; d &lt;/li&gt;
      &lt;li&gt; e &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I need to change the class 'active' of li's in a cycling manner
  Here is the script I'm working with. issue is it either adds the class <em>active</em> to all li's or removes the class <em>active</em> from all li's</p>
  
  <pre><code>      toggleSlide = function(){
            $("#slider ul li").each(function(index) {
              if($(this).hasClass('active')){
  
                $("#slider ul li").removeClass('active');
                $(this).next().addClass('active'));
                //lis = $("#slider ul li")
                //$(lis[(index+1)%lis.length]).addClass('active');
              }
            });
          }
     setInterval(toggleSlide, 5000);​
  </code></pre>