clear table jquery

learning picture learning · Apr 12, 2010 · Viewed 231.6k times · Source

I have an HTML table filled with a number of rows.

How can I remove all the rows from the table?

Answer

rahul picture rahul · Apr 12, 2010

Use .remove()

$("#yourtableid tr").remove();

If you want to keep the data for future use even after removing it then you can use .detach()

$("#yourtableid tr").detach();

If the rows are children of the table then you can use child selector instead of descendant selector, like

$("#yourtableid > tr").remove();