In my HTML page, I have a table with the id ="productsTable", I wanna remove all its elements except the last one.
I started by this code which will remove all the elements:
$('#productsTable').empty();
Don't know the last HTML element but something like this?
$("#productsTable:not(:last-child)").empty();
Try this:
$("#productsTable").find("tr:not(:last)").remove();
DEMO
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