You can use .eq()
and .after()
like this:
$('#my_table > tbody > tr').eq(i-1).after(html);
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.