Delete all rows in an HTML table
this will remove all the rows:
$("#table_of_items tr").remove();
Keep the <th>
row in a <thead>
and the other rows in a <tbody>
then replace the <tbody>
with a new, empty one.
i.e.
var new_tbody = document.createElement('tbody');
populate_with_new_rows(new_tbody);
old_tbody.parentNode.replaceChild(new_tbody, old_tbody)
Very crude, but this also works:
var Table = document.getElementById("mytable");
Table.innerHTML = "";