➥ jQuery Tutorial
➥ jQuery Effects
- jQuery Effects
- jQuery Effects - Fading
- jQuery Effects - Sliding
- jQuery Effects - Animation
- jQuery Stop Animations
- jQuery Callback Functions
- jQuery - Chaining
➥ jQuery HTML
- jQuery - Get
- jQuery - Set
- jQuery - Add Elements
- jQuery - Remove Elements
- jQuery - CSS Classes
- jQuery - css() Method
- jQuery - Dimensions
➥ jQuery Traversing
- jQuery Traversing - Ancestors
- jQuery Traversing - Descendants
- jQuery Traversing - Siblings
- jQuery Traversing - Filtering
➥ jQuery AJAX
➥ jQuery Misc
Tutorial
Descendants of jQuery Traversing
You can use jQuery to identify decedents of an element by traversing down the DOM tree.
A descendant is a person who is a kid, grandkid, great-grandchild, and etc.
Descending the DOM Tree
There are two basic jQuery techniques for traversing the DOM tree:
children()
find()
Method jQuery children()
The children() function takes all of the selected element's direct children.
This method only goes down one level of the DOM tree.
The example below comes back all components that are immediate children of each <div> element:
Illustration:
EXAMPLE ❯
The illustration returns all <div> descendants:
Illustration:
EXAMPLE ❯
find() method in jQuery
The descendant components of the target element are returned by the find() method, all the way back down until the last descendant.
The instance below returns all <span> components that are decedents of <div>:
Illustration:
EXAMPLE ❯
The illustration returns all <div> descendants:
Illustration: