jQuery - DOM Traversing



The jQuery Traversing Methods are used to navigate through the DOM (Document Object Model) and manipulate elements based on their relationships (such as parent, child and sibling) to other elements.

These methods include finding parent elements (parent(), parents()), locating child elements (children()), selecting siblings (siblings()), and navigating to related elements (next(), prev()).

jQuery Traversing Methods

In the following table, we have listed all the jQuery Traversing Methods −

Sr.No. Methods & Description
1 add()

Adds elements to the set of matched elements.

2 children()

Gets children of each element in the set.

3 closest()

Gets the first ancestor element that matches the selector.

4 contents()

Gets the children of each element in the set, including text and comment nodes.

5 each()

Iterates over a jQuery object, executing a function for each matched element.

6 eq()

Reduces the set of matched elements to the one at the specified index.

7 filter()

Reduces the set to elements that match the selector or pass a function's test.

8 find()

Gets descendants of each element in the set, filtered by a selector.

9 first()

Reduces the set to the first element.

10 has()

Reduces the set to elements that have a matching descendant.

11 is()

Checks if elements match a selector, element, or jQuery object.

12 last()

Reduces the set to the last element.

13 next()

Gets the immediately following sibling of each element.

14 nextAll()

Gets all following siblings of each element.

15 nextUntil()

Gets following siblings up to but not including the element matched by the selector.

16 not()

Removes elements from the set.

17 offsetParent()

Gets the closest positioned ancestor element.

18 parent()

Gets the parent of each element in the current set of matched elements.

19 parents()

Gets the ancestors of each element in the current set of matched elements.

20 parentsUntil()

Gets the ancestors of each element up to but not including the element matched by the selector.

21 prev()

Gets the immediately preceding sibling of each element in the set of matched elements.

22 prevAll()

Gets all preceding siblings of each element in the set of matched elements.

23 prevUntil()

Gets all preceding siblings up to but not including the element matched by the selector.

24 siblings()

Gets all sibling elements of each element in the set of matched elements.

25 slice()

Reduces the set of matched elements to a subset specified by a range of indices.

Advertisements