How to remove previous row tr from table in jquery

/ / 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

Thank you for reading, pls keep visiting this blog and share this in your network. Also, I would love to hear your opinions down in the comments.

PS: If you found this content valuable and want to thank me? 👳 Buy Me a Coffee

Subscribe to our newsletter

Get the latest and greatest from Codepedia delivered straight to your inbox.


Post Comment

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

0 Comments