jQuery delete all table rows except first

后端 未结 14 1365
失恋的感觉
失恋的感觉 2021-01-29 17:40

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

14条回答
  •  耶瑟儿~
    2021-01-29 18:04

    Your selector doesn't need to be inside your remove.

    It should look something like:

    $("#tableID tr:gt(0)").remove();
    

    Which means select every row except the first in the table with ID of tableID and remove them from the DOM.

提交回复
热议问题