Tengo un código el cual debe de ingresar o eliminar la última fila según lo necesitemos de una tabla HTML con AJAX
Estos son mis botones:
<button class="btn btn-success addmore" type="button" id="insert-more"> Agregar Artículo</button>
<button class="btn btn-success removebutton" type="button" id="delete-more"> Eliminar Último artículo</button>
Y este el código AJAX:
$("#insert-more").click(function () {
$("#mytable").each(function () {
var tds = '<tr>';
jQuery.each($('tr:last td', this), function () {
tds += '<td>' + $(this).html() + '</td>';
});
tds += '</tr>';
if ($('tbody', this).length > 0) {
$('tbody', this).append(tds);
} else {
$(this).append(tds);
}
});
});
$("#delete-more").click(function () {
$("#mytable").each(function () {
var tds = '<tr>';
jQuery.each($('tr:last td', this), function () {
tds += '<td>' + $(this).html() + '</td>';
});
tds += '</tr>';
if ($('tbody', this).length > 0) {
$('tbody', this).remove(tds);
} else {
$(this).remove(tds);
}
});
});
El botón de agregar filas funciona perfectamente el que no funciona es el de eliminarlas, pensaba que habia entendido el .remove
de Ajax pero veo que no.