How to prepend a tr to after first tr at a table? [duplicate]
Asked Answered
H

3

13

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?

Hedberg answered 4/3, 2011 at 12:35 Comment(2)
Check out the jQuery API on the first selectorWoodchuck
I searched and my question is possible duplication. I found my answer: #4850294Hedberg
T
30

You will want to use jquery after, like this:

$('#myTable tr:first').after($tr);
Tetrode answered 4/3, 2011 at 12:41 Comment(0)
A
10

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);
Anemophilous answered 4/3, 2011 at 12:38 Comment(0)
P
0

You need to use .after

$('#myTable > tbody > tr:first').after($tr);
Pierre answered 4/3, 2011 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.