Why use jQuery(selector).get(0) instead of jQuery(selector)[0] to get DOM element?

前端 未结 4 1509
臣服心动
臣服心动 2021-02-19 02:34

Using jQuery is there any benefit to using $(selector).get(0) over $(selector)[0] if I just want to get the first item in the jQuery array as a DOM ele

4条回答
  •  一个人的身影
    2021-02-19 03:07

    I have too low a rep to comment on ericbowden's answer, but here is a jsperf test comparing the two operations:

    http://jsperf.com/selector-get-0-vs-selector-0

    Consensus (on Chrome 32): Basically the same, very minor advantage towards [0]

提交回复
热议问题