How to remove previous row tr from table in jquery

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

Sharing is Sexy:    
Satinder Singh

Hi all, am Founder and Author of Codepedia.info, also atypical polyglot programmer from Bombay, India. I have a passion to create, solve, and deploy software applications.
       ForEach ( minute in MyLife ) { myExperience++ ; }



Post Comment


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