JQuery selector for table cells except first/last row/column

后端 未结 2 1221
一个人的身影
一个人的身影 2021-02-02 09:52

is there a way to directly select all \'inner\' table cells ( elements) of a table (i.e. all cells except the ones in the first and last

2条回答
  •  梦毁少年i
    2021-02-02 10:07

    You can use :not() with the :first-child and :last-child selectors, like this

    $('table td:not(:first-child, :last-child)')
    

    To exclude first/last rows as well:

    $('table tr:not(:first-child, :last-child) td:not(:first-child, :last-child)')
    

提交回复
热议问题