Bandi Su
Bandi Su

Reputation: 125

Hyperlink JQuery doesn't triggered

I'm using JQuery for adding table row and at the last column I have hyperlink for cancel/delete the row. But it seems my JQuery not triggered when I clicked the hyperlink. Here my code:

$('input[name=barcode]').change(function() {
    var newRow = $("<td><a href='#' class='remove'><font color='0404B4'>Cancel</font></a></td>");
    $('#tab > tbody > tr').eq(index).after(newRow);
});
$(".remove").click(function() {
    //delete row
    alert("b");
});

Upvotes: 0

Views: 35

Answers (1)

Jake Opena
Jake Opena

Reputation: 1525

It is not triggered since the newly added element is not bound to the click event. You can try this code:

$('#tab').on('click', '.remove', function() {
    alert('b');
});

You can get more info over here jQuery on()

Upvotes: 1

Related Questions