I need to make that when clicking the link it removes this tr element that is the link, can someone help me?
<?php foreach ($emails as $v): ?>
<tr>
<td><?= $v->id; ?></td>
<td><?= $v->email; ?></td>
<td class="actions">
<a href="javascript:void(0);" id="<?= $v->id; ?>" class="delete-row delete-newsletter"><i class="fa fa-trash-o"></i></a>
</td>
</tr>
<?php endforeach; ?>
This is my ajax, I tried to do it this way but it deletes all tr, I know I need to access the parent element, but how can I delete the parent element of this id that the guy clicked on?
$(".delete-newsletter").click(function(){
var id = this.id;
$.ajax({
url: path +'administrador/deletarNewsletter',
type: 'POST',
data: {
usuario: id
},
success: function (response) {
console.log(response);
if (parseInt(response) === 1) {
$("tr").remove(); // Aqui ele apaga todos os tr, sendo que quero apagar o que ele clicou
console.log('apagado!');
} else {
console.log('deu merda');
}
},
error: function (erro, er) {
console.log(erro, er);
}
});
});