I know how to append or prepend a new row into a table using jquery:
$('#my_table > tbody:last').append(html);
How to I insert the row (given in the html variable) into a specific “row index” i. So if i=3, for instance, the row will be inserted as the 4th row in the table.
You can use
.eq()and.after()like this: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.