If you select an element in jQuery by ID is there still a speed improvement by giving it a parent to

Posted by user169867 on Stack Overflow See other posts from Stack Overflow or by user169867
Published on 2010-03-15T12:38:03Z Indexed on 2010/03/15 12:39 UTC
Read the original article Hit count: 191

Filed under:

Imagine this simplified markup:

<div id="header">
   <!-- Other things.... -->
   <div id="detail">

   </div>
</div>

and assume you already have this code:

var $hdr = $("#header");

Is there any speed difference for jQuery to lookup "detail" this way:

var $detail = $("#detail", $hdr);

vs

var $detail = $("#detail");

Since detail is being looked up by ID?

© Stack Overflow or respective owner

Related posts about jQuery