Reputation: 357
$('table#Items').on('click','tr input#delItem',function(e){
$(this).closest('tr').remove();
});
Hi all. Please tell me, what is the right solution for removing two table rows in lieu of one? Thank you
Upvotes: 0
Views: 1308
Reputation: 67207
The following code will remove the next and the previous row from the closest row.
Try,
$('table#Items').on('click','tr input#delItem',function(e){
var closestRow = $(this).closest('tr');
closestRow.add(closestRow.prev()).add(closestRow.next()).remove();
});
Upvotes: 6
Reputation: 24276
Here is an example: http://jqversion.com/#!/72F15CA/1
$('table#Items').on('click','tr input#delItem', function(e){
$(this).closest('tr').nextAll().slice(0,2).remove();
});
Upvotes: 3