clear table jquery

后端 未结 10 1685
耶瑟儿~
耶瑟儿~ 2021-01-30 05:03

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

How can I remove all the rows from the table?

10条回答
  •  萌比男神i
    2021-01-30 05:25

    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();
    

提交回复
热议问题