Getting a range of elements in one jQuery selector

后端 未结 3 1068
粉色の甜心
粉色の甜心 2020-12-18 23:31

My problem is that I have a table, but I only want a subset of the rows, from first index to last index. I thought you could do it like this:

$(\'table tr:gt         


        
3条回答
  •  误落风尘
    2020-12-19 00:15

    How about $('table tr').slice(2, 4)

    Since JavaScript arrays are 0 indexed, that will give you the third and fourth row of the table. Slice will still return a jQuery wrapped (sub)set, so it's the same end result.

提交回复
热议问题