I am trying to setup a table to toggle additional ‘detail’ rows. Essentially, the table is loaded, if a row is clicked, it will insert a ‘details’ row after said row. If said row is clicked again, it will remove the ‘details’ row. The following yields unexpected results. I was wondering what the best approach would be?
jQuery('.tasks-table tbody tr').toggle(
function () {
jQuery(this).next().remove();
},
function () {
jQuery(this).after('<tr><td colspan="10"><p style="margin-left: 50px;">lorem ipsum</p></td></tr>');
}
);
toggle does not work that way: http://api.jquery.com/toggle/
what you want is: