title: Add a class via for-loop
body: <p>I have a very simple for-loop in jQuery:</p>
  
  <pre><code>var iEra;
  for(iEra = 1; iEra &lt;= li.length; iEra++) {
      li.addClass(iEra);
  }
  </code></pre>
  
  <p><strong>li</strong> is a variable targeting $('ul.class li') objects. <strong>iEra</strong> is the counter variable that should start from 1 up to the number of <strong>li</strong> objects present.</p>
  
  <p>The main issue is that the function addClass is not happening at all. However if I replace it by, for example, <strong>alert(iEra);</strong>, I will get my 1-x alerts.</p>
  
  <p>I know I could modify my for-loop to be a "constructor", like so:</p>
  
  <pre><code>var iEra;
  for(iEra = 1; iEra &lt;= li.length; iEra++) {
      parentOfli.append('&lt;li class=" + iEra + "&gt;&lt;/li&gt;');
  }
  </code></pre>
  
  <p>That way I would get my classes 1-x added just fine. Problem is, those li objects are already being generated somewhere else.</p>
  
  <p>I hope I explained myself thoroughly; if not, please let me know so!
  Live example: <a href="http://jsfiddle.net/c3cXB/9/" rel="nofollow">http://jsfiddle.net/c3cXB/9/</a></p>