title: jQuery .each() function. Resetting the index?
body: <p>I have multiple lists with the same class.</p>
  
  <p>I'd like to loop each list and its LI's and prepend the current number before each. The current code I have is:</p>
  
  <pre><code>$jQuery(".numberList li").each(function(i) {
  
      var index = i + 1;
  
      $jQuery(this).prepend("&lt;span&gt;" + index + "&lt;/span&gt;");
  
  });
  </code></pre>
  
  <p>The problem is, is that the index doesn't restart back at 0 for each list it goes through, it just keeps going up. For example, the output I get now is:</p>
  
  <pre><code>First list
  1. item
  2. item
  3. item
  
  Second list
  4. item
  5. item
  6. item
  </code></pre>
  
  <p>Second list should start at 1 again by having the index back at 0.</p>
  
  <p>Could someone point out where I'm going wrong? I'm not a jQuery expert or anything...clearly :)</p>
  
  <p>Many thanks,
  Michael.</p>