I have a table like this:
<table id="myTable">
<tr>
<td>Stuff</td>
</tr>
<tr>
<td>Stuff</td>
</tr>
// etc.
</table>
I want to insert a new table row into the above table so it is the second row. I know that I can use prepend() to insert the row as the 1st row, but I can’t figure out how to insert it as the second row. Here is what I am using:
$.ajax({
type: "POST",
url: 'get_new_table_row.php',
success: function(data){
$('table#myTable').prepend(data);
}
});
return false;
How can I modify this to make it insert the new row as the 2nd row in the table?
You can use
aftermethod and:firstselector:or: