title: Re-number the id's of table rows using jQuery
body: <p>I have the following table code:</p>
  
  <pre><code>&lt;tbody&gt;
      &lt;tr data-id='1' id='item-1'&gt;
          &lt;td&gt;30-01-2014&lt;/td&gt;
      &lt;/tr&gt;   
      &lt;tr data-id='19' id='item-2'&gt;
          &lt;td&gt;30-01-2014&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr data-id='5' id='item-3'&gt;
          &lt;td&gt;30-01-2014&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr data-id='39' id='item-4'&gt;
          &lt;td&gt;30-01-2014&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p>and the jQuery:</p>
  
  <pre><code>$('table tbody').sortable({
      axis: 'y',
      update: function (event, ui) {
          var data = $(this).sortable('serialize');
          $.ajax({
              data: data,
              type: 'POST',
              url: 'updatePagesOrder.php'
          });
      }
  });
  var i = 1;
  $('table &gt; tbody  &gt; tr').each(function () {
      $('tr').attr('id', 'item-' + i);
      i++;
  });
  </code></pre>
  
  <p>What I want to do is that after the <code>sortable</code> function executed the id of the items will be ordered again from 1 to 4.
  I have tried to code above, but it didn't work.</p>
  
  <p>Wish for help...Thanks!</p>