jquery - get all rows except the first and last

前端 未结 6 673
暗喜
暗喜 2020-12-23 09:11

i want to dynamically add a class to all rows of a table except the first and last row. how would i do this without assigning a css class to the rows to identify them. I a

6条回答
  •  被撕碎了的回忆
    2020-12-23 10:08

    You can combine the .not() methods into one by separating the selectors with commas:

    $('#id tr').not(':first, :last');
    $('#id tr:not(:first, :last');
    

    Note that the second one is not valid in pure CSS, only as a jQuery selector. For pure CSS you'd have to use @Sumit's answer.

提交回复
热议问题