I am filling a table one by one, but in case you don't want some data, just delete it, this is my table with jquery
var row = '';
row += '<tr >';
row += '<td style="padding:2px">' + XXXX+ '</td>';
row += '<td style="padding:2px;">' + XXXX+ '</td>';
row += '<td style="padding:2px;">' + XXX+ '</td>';
row += '<td style="padding:2px;">' + XXX+ '</td>';
row += '<td style="padding:2px;"><button class="btn btn-danger" onclick=\"Eliminar(\'' + ID+ '\')\">Eliminar</button> </td>';
$('#table').append(row);
When clicking on the delete button, I send as a parameter the id of the row that you want to delete to a function
function Eliminar(ID)
{
$("#table" + unidad).parent().parent().remove();
}
I try to delete the row in this way, but nothing happens, however if I inspect the code, if it is taking the ID, how can I delete the row?
Add a class to the button and create a click handler. Then inside the handler use
this
. So: