Reputation: 73888
var data = $('tbody');
console.log(data.filter(':first'), data.filter('tr.ay-sort-top'));
data.filter(':first').before(data.filter('tr.ay-sort-top'));
Console output from two runs:
[<tr class="ay-sort-top">…</tr>] [<tr class="ay-sort-top">…</tr>]
[<tr>…</tr>] [<tr class="ay-sort-top">…</tr>]
Upvotes: 0
Views: 2950
Reputation: 30463
For example: $('tr:eq(2)').prependTo('table');
See DEMO: http://jsfiddle.net/LxKSq/2/
Upvotes: 4
Reputation: 150070
If your question is actually "How do I move any rows with the "tr.ay-sort-top" class to the top of the table, leaving other rows in place?" then you can do something like this:
var $tbody = $("#yourTable tbody");
$tbody.prepend( $tbody.find("tr.ay-sort-top") );
Demo: http://jsfiddle.net/b89zY/1/
Upvotes: 0