DOM Traversal methods
DOM Traversal methods
jQuery traversing is used to "find" (or select) HTML elements based on their relation to other elements. jQuery traversing means "move through" is used to "find" (or select) HTML elements based on their relation to other elements. Some of the Traversal Methods are:-
parent()
direct parent element of the selected element.
Syntax:-
Its syntax is:- $(selector).parent(filter)
Further Explanation:-
Parameter | Description |
---|---|
filter | Optional. Specifies a selector expression to narrow down the parent search |
parents()
all ancestor elements of the selected element.
Syntax:-
Its syntax is:- $(selector).parents(filter)
Further Explanation:-
Parameter | Description |
---|---|
filter | Optional. Specifies a selector expression to narrow down the search for ancestors |
children()
all direct children of the selected element.
Syntax:-
Its syntax is:- $(selector).children(filter)
Further Explanation:-
Parameter | Description |
---|---|
filter | Optional. Specifies a selector expression to narrow down the search for children |
siblings()
all siblings element.
Syntax:-
Its syntax is:- $(selector).siblings(filter)
Further Explanation:-
Parameter | Description |
---|---|
filter | Optional. Specifies a selector expression to narrow down the search for sibling elements |
next()
next siblings element
Syntax:-
Its syntax is:- $(selector).next(filter)
Further Explanation:-
Parameter | Description |
---|---|
filter | Optional. Specifies a selector expression to narrow down the next sibling search |
prev()
prev siblings element
Syntax:-
Its syntax is:- $(selector).prev(filter)
Further Explanation:-
Parameter | Description |
---|---|
filter | Optional. Specifies a selector expression to narrow down the previous sibling search |