title: How to properly add alternate class to even table rows on multiple tables with the same class using jQuery?
body: <p>This is usually a very straight forward thing to do, so before you down vote me for such a question hear me out :)</p>
  
  <p>My problem is not selecting the elements and adding the class, it's that I want the alternate class to be added to even or odd rows <em>relative to that table</em>.</p>
  
  <p>Right now I am using this:</p>
  
  <pre><code>jQuery(document).ready(function(){
  
  jQuery('table.rep tbody &gt; tr td:first-child').addClass('composer');
  jQuery('table.rep tbody &gt; tr td:last-child').addClass('pieces');
  jQuery('table.rep tbody &gt; tr:odd').addClass('alt');
  
  });
  </code></pre>
  
  <p>The problem is that jQuery is selecting all of the rows from all of the tables with the "rep" class and then adding the "alt" class to the odd rows from that set.</p>
  
  <p>Like I said, I want to have it apply the class to the even/odd rows relative to each table, so the first row would always be styled the same way.  As it is using the code above, the first rows can be either alt/normal based on how many rows are in the previous table.</p>
  
  <p>I was thinking of somehow using the <code>.each()</code> function, but after looking through the jQuery docs, I haven't been able to find out how to achieve my desired result.</p>
  
  <p>I'm thinking it might look something like this:</p>
  
  <pre><code>jQuery('table.rep').each(function(){
      /* select/filter odd rows from this set and add alt class */
  });
  </code></pre>
  
  <p>So my question is if <code>.each()</code> can be used like that and if so, how to drill down into the results of each iteration and make it do what I want.</p>