I am trying to insert a new row before the last (n-th) row in a table. However, Using the code below it instead nests the new
<tr></tr>
inside the n-th <tr></tr>
. Making the output look like this:
<tr><tr></tr></tr>
This is the code:
$('#sbdrp_table > tbody tr:last-child')
.append('<tr><td>my data</td><td>more data</td></tr>');
This is the outcome:
<tr><td colspan="2"><input style="width: 100%" type="button" class="add-row x" value="+ Add"></td>
<tr><td>my data</td><td>more data</td></tr>
</tr>
Expected Outcome The new row should come before the last row.