jQuery .children () Method

Last Updated Jul 21, 2015, 12:00:06 PM





jQuery .children () Method

jQuery children() method is used to get the children of each and every element in the set of matched elements and constructs a new jQuery object from the matched elements in the DOM tree.

In jQuery, the children() method is different from jQuery find() method method. meaning .children() method only travels a single level down the DOM tree where as .find() can traverse down multiple levels to select elements.

It accepts optional parameter i.e., selector expression of the same type.

Syntax

Let's look at an example of using the jQuery children() traversal method.



If you notice the above HTML It has child elements and parent elements as well. Using the below jquery children method we target the direct children of ul Output

The above example produces the following result.


jquery children() method

Try It Now

Other Advanced jQuery Traversing Methods you might want to learn

jQuery Traversal Reference

jQuery Basic Traversing

jQuery Traversal Filters

jQuery Traversing Methods

Sources and Credits

The content and methods in the tutorial has been referred and updated with jQuery API and The jQuery Foundation

Last Updated Jul 21, 2015, 12:00:06 PM