i have a table and i have two buttons to add and remove rows to this table .
so adding row is easy (i get 3 rows via ajax every time) .
now i want to be able to remove last 3 rows of table by clicking on remove button so unless there is some kind of function or .... to remove recent additions to my table ! i need to remove last three rows of table myself
something like
$('#tbl tr:lt(3)').remove();
but last 3 not first ones !
or i have to do something stupid like
function remove(){
var i ;
for(i=0 ; i < 3 ; i++ ){
$('#table tr:last').remove();
}
alert('removed');
}
$("table tr").slice(-3).remove();
It's not so stupid, it's a nice workaround. To clean it up, I'd use
function remove(){
$('#table tr:last').remove();
$('#table tr:last').remove();
$('#table tr:last').remove();
alert('removed');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With