tags:

views:

274

answers:

2
<table id="tab">
<tbody>
...
</tbody>
</table>

Likve above,there is already <tbody> inside <table>, $.append will make it to the end of <table>,how to make it to the beginning?

EDIT

I need to add a callback once new added <tbody> is in DOM,how?

A: 

Try the following:

$("#tab tbody:first").before("<tbody>Your text here</tbody>");
David Andres
+6  A: 

uh .. $.prepend() ?

Scott Evernden
That would be the correct answer, Scott!
Phil.Wheeler
Seems it's more cool!
Shore
Wait,how to add a callback to it?
Shore
@Shore, What do you mean by callback?
strager
Something like $.load(..,callback)
Shore
$.prepend() will not return until the tbody is successfully prepended (no need for a callback, just write code after)
cobbal