The parents() method is used to pick all ancestor elements of an element. This function is used to locate all of the parent elements of the current element. This function returns all elements after traversing all levels up to the selected element.