Traversing means "moving through". JQuery provides a variety of methods that allows us to traverse the DOM. Jquery Traversing methods are used to find or select HTML elements based on their relation to other elements. The traverse starts from one selection and move through that selection until you reach the desired elements.
The JQuery traversing methods enable you to easily move up to the ancestor elements, move down to descendant elements and move sideways to sibling elements in the family tree, starting from the current element. This movement is called traversing also known as moving through the DOM. The largest category of traversal methods are tree-traversal. Here is a brief description of all jQuery Traversing methods.
Adds elements to the existing group of matched elements.
The andSelf( ) method adds the previous selection to the current selection.
The children() method returns all direct children of the selected element.
The closest() method returns the first ancestor of the selected element.
The contents() method returns all direct children, including text and comment nodes, of the selected element.
The end() method end the most recent filtering operation in the current chain and return the set of matched elements to its previous state.
The find() method returns descendant elements of the selected element.
The next() method returns the next sibling element of the selected element.
The nextAll() method returns all next sibling elements of the selected element.
The offsetParent() traverses along the DOM tree and searches through the ancestors of the selected element and construct a new jQuery object wrapped around the closest positioned ancestor.
The parent() method returns the direct parent element of the selected element.
The prev() method returns the previous sibling element of the selected element.
The prevAll() method returns all previous sibling elements of the selected element.
The siblings() method returns all sibling elements of the selected element.