Reputation: 125
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
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