Referencing the top row of a table
<p>I would like the following script to move a table row to the top of a table. I can't figure out how to reference the id of the first row, however, since the ID is set dynamically, I tried <code>row.insertAfter(row.first());</code> but it's making the row disappear instead of moving it. Any ideas how to reference the top row?</p>

<pre><code>    $(".top").click(function(){
        var row = $(this).parents("tr:first");
        if ($(this).is(".top")) {
            row.inserAfter(row.first());
        } else {
            return false;
        }
    });


&lt;tbody id="sortable"&gt;
  &lt;tr id="row1"&gt;
    &lt;td&gt;&lt;a href="" class="top"&gt;Top&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr id="row2"&gt;
    &lt;td&gt;&lt;a href="" class="top"&gt;Top&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr id="row3"&gt;
    &lt;td&gt;&lt;a href="" class="top"&gt;Top&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;
</code></pre>
