jQuery: children() VS. find() – which is faster?

Posted on: Mar 16, 2009 by wenbert

This is from stackoverflow and I am re-posting it here on my blog for record purposes. There is so much useful information there that in the days to come I will probably doing a bunch of re-posts from stackoverflow.com

//For example:
$(this).children('.foo');
//gives the same result as:
$(this).find('.foo');

The answer is:

Children only looks at the immediate children of the node, while find traverses the entire DOM below the node, so children will be faster. Which to use depends on whether you only want to consider the immediate descendants or all nodes below this one in the DOM.

Thanks to bartclaeys and tvanfosson from stackoverflow…


Subscribe to comments Comment | Trackback |
Post Tags: ,

Browse Timeline


Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">


© Copyright 2007 eKini Web Developer Blog . Thanks for visiting!