I have a table with rows in it. When I click a button it is removes the row prior to it. I am using the closest() function to determine the row. I would like to delete the same row that the button is in.
function DeletClick(id, date) {
var e = window.event; \
if (confirm('Are you sure you want to delete the record from ' + date + '?')) {
DisplayInformation.Delete(id,
function (result) {
if (result) {
jQuery('#' + e.srcElement.id).closest('tr').remove(); //Delete Row here!
} else {
alert('You Do not have permssion to delete record.');
}
});
}
}
If the button is inside the td of the specific row, then you can use the same logic to determine the current row,
Assuming
DeletClickfunction is the click handler for the delete button.In case if you have binding the event handler inline of the button HTML like below then you need to pass the
thisas an arg to the function and update thethisin the above code with that argument.Then inside the function,