Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery difference between searching 'children' and 'find'?

Tags:

jquery

When is one preferred over the other when searching for nested Divs?

like image 458
zsharp Avatar asked Mar 05 '10 05:03

zsharp


People also ask

What is the difference between FIND and children in jQuery?

The find() method traverses the entire Dom whereas the children() method gets the immediate children of the node. The children() method is to get the immediate children of the node.

What is the difference between FIND and children's method in Javascript?

difference between find() and children() methods in jquery : Both find() and childern() are jquery methods. find() method is used to search the more then one level down the tree (DOM tree) while children() method is uesd to find the single level down the tree. childern() method is faster than find() method.

What is the difference between FIND and children's method Mcq?

Find method is used to find all levels down the DOM tree but children find single level down the DOM tree.

What is the main difference between the contents () and children ()?

As said here, the main difference is that with . contents you'll get a list, while with . children you'll get a generator.


1 Answers

Find is recursive, where children looks only 1 level deep in the DOM. Check out this: http://blog.ekini.net/2009/03/16/jquery-children-vs-find-which-is-faster/

Note: that is actually references a Stackoverflow post.

Either way, that should help answer your question. If you need to search more than one level use Find, if not use children as it is faster.

like image 96
Dustin Laine Avatar answered Oct 30 '22 06:10

Dustin Laine