jQuery :first vs. .first()

前端 未结 4 1728
夕颜
夕颜 2020-11-29 01:12

The .first() method was added in jQuery 1.4.

The :first selector has been around since 1.0.

From the docs:

:first

4条回答
  •  -上瘾入骨i
    2020-11-29 02:08

    The :first pseudo selector and first() can do the same thing.

    As for performance, here is a live example of performance difference between jQuery first(),:first, eq(0) and :nth(0).

    http://jsperf.com/jquery-first-vs-first-selector, Please check it out!

    Hope this will help.

提交回复
热议问题