Using jQuery, how do I delete all rows in a table except the first? This is my first attempt at using index selectors. If I understand the examples correctly, the following sh
Easiest way :
$("#mytable").find($("tr")).slice(1).remove()
-first reference the table
-get the list of elements and slice it and remove the selected elements of the list
wrapped in a function:
function remove_rows(tablename) {
$(tablename).find("tr:gt(0)").remove();
}
then call it:
remove_rows('#table1');
remove_rows('#table2');