What is Traversing?
The jQuery selectors allow us to select the elements down the DOM tree. But in some cases, you need to select a parent or ancestor element. With jQuery traversing method, you can traverse up, down and all around the DOM tree. The traversing enables you to navigate through an HTML page to find the exact location at which you need to gather some data or make a change.
The following image describes an HTML page as a DOM tree. Using jQuery traversing you can easily move up, down and sideways in the tree, this movement is called traversing or navigating through the DOM tree.
In the above image:
An ancestor is a parent, grandparent, great-grandparent and so on, and a descendant is a child, grandchild, great-grandchild and so on. Siblings elements are those elements that share the same parent.
Traversing the DOM Tree:
It is important to understand the logical relationships between the elements in a DOM tree. In our next topics, you will learn how to perform various traversing operations such as traversing up, down and sideways the DOM tree using the jQuery.