jQuery delete table column

前端 未结 6 599
北荒
北荒 2020-12-17 00:40

I have a table and cannot change markup:

6条回答
  •  眼角桃花
    2020-12-17 01:18

    If you have the static html (consider table with 10 columns),

    then remove the first column along with header using below:

     $('#table th:nth-child(1),#table td:nth-child(1)').remove();
    

    now the new table will have 9 columns , now you can remove any column using the number:

     $('#table th:nth-child(7),#table td:nth-child(7)').remove();
    

提交回复
热议问题