I am trying to sort the <tr>
elements within a <table>
that looks like this:
Before
<table>
<tbody>
<tr id="foo">...</tr>
<tr id="bar">...</tr>
<tr id="baz">...</tr>
<tr id="qux">...</tr>
</tbody>
</table>
Suppose I want to sort the rows so that the table becomes like this:
After
<table>
<tbody id="table">
<tr id="foo">...</tr>
<tr id="qux">...</tr>
<tr id="baz">...</tr>
<tr id="bar">...</tr>
</tbody>
</table>
I can do this by using a sequence of jquery scripts:
$('#table').append($('#qux'));
$('#table').append($('#baz'));
$('#table').append($('#bar'));
but I want to make the scripts into one, and when I try:
$('#table').append($('#qux,#baz,#bar'));
on the original table, it does not seem to have any effect. Why is this not working? Is there a way to do this in one command?