title: Auto incrementing ids when jQuery creates the element
body: <p>I have a table that I am creating tr.'s and td's for when the person clicks the button. This is working wonderfully, except I need to be able to add id's to those tr's and have them auto increment.</p>
  
  <p>My full code looks like this</p>
  
  <pre><code> $("#moreRows").click(function () {
       var rowCount = $('table tr').length -1;
       if(rowCount &gt;= 100)
       {
          alert('you have 100 rows');
       }else{
           $("#correctionTable").each(function () {
               var tds = '&lt;tr&gt;';
               jQuery.each($('tr:last td', this), function () {
  
                   tds += '&lt;td&gt;' + $(this).html() + '&lt;/td&gt;';
               });
               tds += '&lt;/tr&gt;';
               if ($('tbody', this).length &gt; 0) {
                   $('tbody', this).append(tds);
                   $('tbody', this).append(tds);
                   $('tbody', this).append(tds);
                   $('tbody', this).append(tds);
                   $('tbody', this).append(tds);
               } else {
                   $(this).append(tds);
               }
           });
       } 
       return false; 
  }); 
  </code></pre>
  
  <p>and so far I have tried something like this (not the complete each function I know, just an example)</p>
  
  <pre><code>var num = 5;
    $("#correctionTable").each(function () {
     var id = num++;
     var tds = '&lt;tr id="'+id+'"&gt;';
  </code></pre>
  
  <p>to try and add the id to the original tr within the each loop. This just adds the id of 6 to each tr.</p>
  
  <p>I have also tried this</p>
  
  <pre><code>var num = 5;
   $("#correctionTable").each(function () {
     tds = '&lt;tr id="' + (++num) + '"&gt;';
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>var num = 5;
    $("#correctionTable").each(function () {
    ++num
     tds = '&lt;tr id="' + num + '"&gt;';
  </code></pre>
  
  <p>but neither have worked</p>
  
  <p>I have also tried moving that function within the .each function where it is attaching the td to the last tr, but it did not like me adding anything to a variable or replacing that variable to anything else.</p>
  
  <p>Any help would be amazing, I am just plain stuck!</p>
  
  <p>A jsFiddle to show I am not crazy <a href="http://jsfiddle.net/bwHnq/33/" rel="nofollow">http://jsfiddle.net/bwHnq/33/</a></p>