title: jQuery: adding a class to child elements x number of times
body: <p>I have a div called starRating which displays 5 grayed-out stars. I am given a number and based on that number I need to add a css class that changes the grayed-out star to the colored one. Is this something I would accomplish in a for loop or with .each?</p>
  
  <p>Here is the HTML:</p>
  
  <pre><code>&lt;div id="starRating"&gt;
     &lt;div class="jquery-ratings-star"&gt;&lt;/div&gt;
     &lt;div class="jquery-ratings-star"&gt;&lt;/div&gt;
     &lt;div class="jquery-ratings-star"&gt;&lt;/div&gt;
     &lt;div class="jquery-ratings-star"&gt;&lt;/div&gt;
     &lt;div class="jquery-ratings-star"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And here is what I've been attempting to do. This seems as if I am over-complicating it.</p>
  
  <pre><code>$('.jquery-ratings-star').each(
          function() {
             for (var i = 0; i &lt; nbrStarsVoted; i++) {
             $(this).addClass('.jquery-ratings-full');
                          }
   });
  </code></pre>