title: jQuery - add classes to separate elements in order?
body: <p>I have classes with different values in them and i want to add those classes to set elements in order.</p>
  
  <p>This is supposed to be just an explanation of what im looking for:</p>
  
  <pre><code>&lt;div class="These"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These"&gt;Lorem ipsum&lt;/div&gt;
  
  $('.These').each(function() {
      var TheseINDEX = $(this).index();
      $(this).addClass('first, second, third');
  });
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>&lt;div class="These first"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These second"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These third"&gt;Lorem ipsum&lt;/div&gt;
  </code></pre>
  
  <p>Not like that abomination above was perfect but theres another thing.. I'm also thinking that it would be cool if that would loop.</p>
  
  <p>Lets say i have 3 classes just like before and those 3 classes would be added to 8 elements</p>
  
  <p>Result would be this:</p>
  
  <pre><code>&lt;div class="These first"&gt;Lorem ipsum&lt;/div&gt; &lt;!-- #1 --&gt;
  &lt;div class="These second"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These third"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These first"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These second"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These third"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These first"&gt;Lorem ipsum&lt;/div&gt;
  &lt;div class="These second"&gt;Lorem ipsum&lt;/div&gt; &lt;!-- #8 --&gt;
  </code></pre>
  
  <p>as in it would keep adding these preset classes until theres no ".These" for them to be added to. This looping would work much like a backup incase you run out of classes...</p>
  
  <p><a href="http://jsfiddle.net/Z4PAZ/" rel="nofollow">http://jsfiddle.net/Z4PAZ/</a> -  jsfiddle of my example..</p>
  
  <p>Any ideas?</p>