I need that when you insert a row in the table to be able to capture that event to be able to calculate the total of ages and in the case that rows are eliminated subtract the ages thanks.
I tried using onchange
and update
without results:
$("#table_datos").on("change", function() {
alert("cambio detectado");
});
$('#table_datos').on('update', function(){
alert("cambio detectado");
});
<table id="table_datos">
<thead>
<tr id="1">
<th>Nombre</th>
<th>Edad</th>
</tr>
</thead>
<tbody>
<tr id="2">
<td>Jorge</td>
<td>18</td>
</tr>
<tr>
<td>Juan</td>
<td>21</td>
</tr>
</tbody>
</table>
$('#table_datos').append('<tr id='+token+'><td>'+variable1+'</td><td >'+variable2+'</td><td><button type="button" onclick="Eliminar('+token+');"> Eliminar </button></td></tr>')
function Eliminar(token){
$('#'+token).remove();
}