简体   繁体   English

如何在第二个位置使用jquery向一个表追加一行?

[英]how to append a row to a table with jquery in second position?

I'm trying to add a row to a table with jquery. 我正在尝试使用jquery向表中添加一行。 I would like to add the row in first position, but not the very first, I want it to come after the row dedicated to the column headers 'th'. 我想在第一个位置添加行,但不是第一个,我希望它在专用于列标题'th'的行之后。 If I try 如果我试试

$('#tableid').prepend() 

obviously the new row comes before the one of 'th's. 很明显,新的排在第一个之前。 Any idea of how to do that? 知道如何做到这一点?

Assuming your first tr that holds the th you could do: 假设你的第一个tr持有的th你可以这样做:

$('#tableid tr:first').after(newTrContent);

Or you if have them separated out into thead and tbody then you could just do. 或者你是否将它们分成了thead和tbody然后你可以做到。

$('#tableid tbody').prepend(newTrContent);

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM