ahmed elgendy ahmed elgendy - 7 months ago 21
Javascript Question

How to remove row in shown table by clicking on delete button in jquery

I have table that created by "HTML Helper" contain two columns the first column include file name and the second column include button with value "delete" , I want to remove the row by clicking on delete button ,
I tried to do this but it is not work
this image contain on the code that used to create the table
enter image description here
and this image contain on JQuery code

enter image description here

Answer

Like this:

$('#tb2').on('click', '.rmv1', function() {
    $(this).parents('tr').remove();
});

Or as you did, but actually calling the remove function:

$('#tb2').on('click', '.rmv1', function() {
    $(this).parent().parent().remove();
});
Comments