I have tried various options for deleting dynamically added rows, like .on
and .live
, but still haven't been able to delete the newly added rows.
And I came across this JSFiddle
Partial JS code:
$(".deleterow").on("click", function(){
var $killrow = $(this).parent('tr');
$killrow.addClass("danger");
$killrow.fadeOut(2000, function(){
$(this).remove();
});
});
but it also has the same issue.
Can someone please point out what am I missing in this JSFiddle?
Thanks.
use Event Delegation to register the click event handler to the dynamically created rows. Try this:
$(".container").on('click','.deleterow', function(){
var $killrow = $(this).parent('tr');
$killrow.addClass("danger");
$killrow.fadeOut(2000, function(){
$(this).remove();
});
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments