可能重复:
Inserting new table row after the first table row using JQuery如何在一个表的第一个tr之后加上tr?
我已填充我的表中的TR和我想要的firts TR后加前缀。我使用这个:
$('#myTable').prepend($tr);
像往常一样,它增加了我的新的顶端。
我该如何添加它作为第二?
可能重复:
Inserting new table row after the first table row using JQuery如何在一个表的第一个tr之后加上tr?
我已填充我的表中的TR和我想要的firts TR后加前缀。我使用这个:
$('#myTable').prepend($tr);
像往常一样,它增加了我的新的顶端。
我该如何添加它作为第二?
你可以做一件事,保持表格的第一个tr到<thead>
,并将其余的tr保存到表格的<tbody>
。
现在做
$('#myTable tbody').prepend($tr);
您需要使用.after
$('#myTable > tbody > tr:first').after($tr);
退房jQuery的API上的[第一选择器](http://api.jquery.com/first-selector/) – 2011-03-04 12:43:02
我搜索了我的问题是可能的重复。我发现我的答案:http://stackoverflow.com/questions/4849794/inserting-new-table-row-after-the-first-table-row-using-jquery – kamaci 2011-03-04 12:44:20