I know that isn't first topic of this type but I have read almost all similar topics and proposed solutions don't work.
I have table with 8 handmade rows, there is also add row button which adds row in this way:
function addNewRow(){
var numRows = $('#newTasks tr').length;
$('#newTasks').append('<tr id="row'+numRows+'"><td><input type="text" id="title-'+numRows+'" /></td><td><input type="text" id="description-'+numRows+'" /></td><td><input type="button" id="delete-'+numRows+'" class="deleteButton" value="x" /></td></tr>');
}
As you can see I have delete button in each row but in dynamically generated rows it doesn't work.
$(document).ready(function(){
[...]
//Delete button click event
$('.deleteButton').click(function(){
alert($(this));
deleteRow($(this));
});
});
Even alert action isn't triggered by dynamically generated button but in case of handmade rows it works fine. I think it doesn't treat dynamically generated buttons as classified "deleteButton" but from the other hand css does.
function deleteRow(thisButton){
thisButton.parent().parent().remove();
}