SNEH PANDYA
SNEH PANDYA

Reputation: 797

unable to delete row from table using jquery?

I just wanted to delete row from respective row. I have tried code for that you can see in JSFIDDLE.Its quite simple but still i am getting error. my code for removing tr is

$(document).ready.(function(){
 $("#table-lst-regions .deleteLink").on("click",function() {
    var tr = $(this).closest('tr');
    tr.css("background-color","#FF3700");

    tr.fadeOut(400, function(){
        tr.remove();
    });
  return false;
});

Upvotes: 2

Views: 237

Answers (1)

Daniil Grankin
Daniil Grankin

Reputation: 3933

Problem is that new added .deleteLink are not subscibed on click

You can change for example defenition for delete link with onclick attribute

<a class ="deleteLink" onclick="deleteRow(this);">

and add function delete

function deleteRow(el) {
        var tr = $(el).closest('tr');
        tr.css("background-color","#FF3700");

        tr.fadeOut(400, function(){
            tr.remove();
        });
      return false;
    }

Take a look http://jsfiddle.net/48MRf/2/

Upvotes: 1

Related Questions