How to prepend a tr to after first tr at a table?

22.2k Views Asked by At

Possible Duplicate:
Inserting new table row after the first table row using JQuery

I have populated a tr for my table and I want to prepend it after the firts tr. I use this:

$('#myTable').prepend($tr);

As usual, it adds my new tt to the top.

How can I add it as second?

3

There are 3 best solutions below

0
On BEST ANSWER

You will want to use jquery after, like this:

$('#myTable tr:first').after($tr);
0
On

You can do one thing keep the first tr to <thead> of the table and rest tr to <tbody> of the table.

Now do

$('#myTable tbody').prepend($tr);
0
On

You need to use .after

$('#myTable > tbody > tr:first').after($tr);