I have a html table like so -
<table class="table" id="myTable">
<thead>
<th>Email</th>
<th>Delete</th>
</thead>
<tbody>
</tbody>
I can dynamically add to the table doing this:
var tbody = $('#myTable').children('tbody');
var table = tbody.length ? tbody : $('#myTable');
table.append("<tr><td>"+user_email+"</td><td><input type='button' value='Del' id ='"+user_id+"'class='btn btn-danger btn-sm'></td></tr>");
But when I try to remove a row doing this:
$('input[type="button"]').click(function(e){
$(this).closest('tr').remove()
})
The row don't remove. How do I resolve this?