Jquery, Clear / Empty all contents of tbody element?

前端 未结 6 1076
萌比男神i
萌比男神i 2021-01-30 12:06

I thought this would be rather simple but it seems the empty method is not working to clear out a tbody that I have. I would appreciate if anyone knows a proper way to do this,

6条回答
  •  借酒劲吻你
    2021-01-30 13:01

    Without use ID () , it is a great way to cope with this issue

    $('#table1').find("tr:gt(0)").remove();

    PS:To remove specific row number as following example

    $('#table1 tr').eq(1).remove();

    or

    $('#tr:nth-child(2)').remove();

提交回复
热议问题