I have a button, #add
, which when clicked adds a row into a table. The last cell of the newly inserted row has a delete icon which if clicked I would like to remove the row.
I believe I'm 95% of the way there but for when clicking the delete icon nothing happens? Would this be due to the DOM needing a refresh?
$(document).ready(function(){
$('#add').click(function() {
$('tbody').append("<tr><td>test</td><td></td><td data-editable='true'>1</td><td><center><i id='delete' class='fa fa-trash-o'></i></center></td></tr>");
$('#table').editableTableWidget();
});
$('#delete').click(function(){
$(this).closest('tr').remove();
console.log('click');
})
});