jQuery “parents() Method ” is used to get all ancestors of the selected element.
Syntax : jQuery parents() method
$(selector).parents(filter);
filter : It is optional, A selector expression used to match(parent) the elements against.
$(selector).parents(filter);
filter : It is optional, A selector expression used to match(parent) the elements against.