jquery - get all rows except the first and last

前端 未结 6 656
暗喜
暗喜 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 09:49

    Strange the suggestions posted did not work, they should all work! BUT...

    If it did not work, do it this way.... slightly slower but MUST WORK!! TRY:

    $('table#tbl tr').addClass('highlight');
    $('table#tbl tr:first-child').removeClass('highlight');
    $('table#tbl tr:last-child').removeClass('highlight');
    

提交回复
热议问题