Remove row from table

I try to delete the row on click last 'td' contain class '.del' in each row except second row. Check this link for demo of the code

Please help me to correct the code

jQuery(".del").click(function () {
    jQuery(this).closest("tr:not(':first')").remove();
    //jQuery(this).closest("tr").remove();
});

Answers


You can try:

jQuery(".del").click(function() {
     jQuery(this).closest("tr:not(':first-child')").remove();
});

jQuery(this).closest("tr:not(':first')") - this is effectively "select closest tr, which is exactly 1 element, then remove :first element from the set, i.e. leave none".


Try

jQuery("tr:not(:first-child) .del").click(function() {
    jQuery(this).closest("tr").remove();
    //jQuery(this).closest("tr").remove();
});

 jQuery(".del").click(function() {
  $tr = jQuery(this).closest("tr");
  if(!$tr.is(':first-child')) {
   $tr.remove();
  }
 });

Need Your Help

Extending (sliding down) JTable row

java swing jtable jpanel

I use jPanel as my cell and the table has just one column. It looks like this ( JTable: Buttons in Custom Panel in Cell ).

SQL Query using birth dates

sql database oracle

I need to find how many students between the ages of 25-29 are currently EXCLUDED on the registration system for being over 25.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.