jQuery parents() Method
jQuery parents() Method
The parents() method is used to return all ancestor elements of the selected element. It can be a parent, grandparent, great-grandparent, and so on. It traverses up to the root element.
Some of its properties are:-
- It begins with the parent element
- Travels up the DOM tree and returns all ancestors that match the passed expression
- The returned object contains zero or more than one 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 |