Performance of jQuery selector with context

后端 未结 6 1428
南方客
南方客 2020-12-01 05:26

I was reading this article by Brandon Aaron here, about how jquery context may help. So i thought of doing a test of my own. So this is what I did.

  1. Created

6条回答
  •  再見小時候
    2020-12-01 06:29

    For what it's worth, $context = $("#context") is still using a jQuery object, which then has to be converted to a DOM object.

    If you use $context = $("#context")[0] you'll find that it runs just as fast as the first test.

提交回复
热议问题