How to remove previous row tr from table in jquery

satinder singh / Updated : / 0 Comments

Overview: Remove previous row tr from the table or Delete previous table row on click in jquery. This article explains how to remove the previous row .i.e  delete previous table row. For selecting previous element we use .prev() and with .remove() method it delete that selected element.

Description : .prev( [selector ] )   , .remove()

Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.

Code: 

//**
 
$("#tbUser").on('click', '.btnDelete', function () {
    $(this).closest('tr').prev().remove();
});

//**

 VIEW DEMO


Post Comment


Your email address will not be published. Required fields are marked *