Basically what I need to do is to “move” an HTML element, not position-wise but location of it’s DOM structure.
Eg
<table id="main">
<tr id="row1"><td></td></tr>
<tr id="row2"><td></td></tr>
<tr id="row3"><td></td></tr>
</table>
How do I move “tr#row3” to the top of “table#main”?
Can use jQuery.
Another way:
or you could also do:
as IDs are supposed to be unique.
Note that although you don’t specify a
tbodyelement, the browser will always insert one. That’s why you cannot just prepend the row to thetableelement.Update: To be correct, in fact you can, as @Šime Vidas pointed out.
Reference:
prepend