jQuery difference between :eq() and :nth-child()

前端 未结 8 2344
一个人的身影
一个人的身影 2020-12-02 15:26

In jQuery, what are some of the key differences between using :eq() and :nth-child() to select any elements ?

Also in general, for the starting index, in which case

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 16:19

    :eq is array indexed based, so it starts from 0. It is also not part of the Css specification.

    Whereas :nth-child is part of the Css specification and refers to the element position in a DOM tree.

    In terms of usage, they both do the same thing.

    Demo here

提交回复
热议问题