jquery selector - exclude first and second

前端 未结 5 1947
无人共我
无人共我 2021-02-13 11:56

I want to exclude first and second element from jquery selector. I tried this:

$(\'p:not(:nth-child(1),:nth-child(2))\')

But this only excludes

5条回答
  •  被撕碎了的回忆
    2021-02-13 12:16

    Simply:

    $('p:gt(1)')
    

    http://api.jquery.com/gt-selector/

    Demo http://jsfiddle.net/NtFYq/1/

    As Alnitak has pointed out in the comment, if performance is a concern, you can use his solution of slice

    Thanks a lot @Alnitak for pointing that out :)

提交回复
热议问题