且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Jquery在某个索引处将新行插入表中

更新时间:2022-12-12 15:34:06

您可以使用 .eq() .after() 像这样:

You can use .eq() and .after() like this:

$('#my_table > tbody > tr').eq(i-1).after(html);

索引是基于0的,所以要成为第4行,你需要 i-1 ,因为 .eq(3)将是第4行,你需要回到第3行( 2 )并插入 .after() 即。

The indexes are 0 based, so to be the 4th row, you need i-1, since .eq(3) would be the 4th row, you need to go back to the 3rd row (2) and insert .after() that.