Easy Tutorial
❮ Misc Isplainobject Eff Dequeue ❯

jQuery children() Method

jQuery Traversing Methods

Example

Return the direct children of a <ul>:

Result:


Definition and Usage

The children() method returns all direct children of the selected element.

DOM Tree: This method only traverses a single level down the DOM tree. To traverse multiple levels down (to return descendants or other offspring), use the find() method.

Tip: To traverse a single level up the DOM tree, or to traverse all the way up to the document root (to return parent nodes or other ancestors), use the parent() or parents() methods.

Note: This method does not return text nodes. To return all child nodes including text nodes, use the contents() method.


Syntax

Parameter Description
filter Optional. Specifies a selector expression to narrow down the search for child elements.

More Examples

Return all direct children of a <ul>

Narrow down the search

Return all <p> elements among the direct children of a <div>

Demonstrate descendants of elements by tag name


jQuery Traversing Methods

❮ Misc Isplainobject Eff Dequeue ❯