closest method

closest

Returns the closest ancestor element (or the element itself) that matches the specified CSS selector.

Returns

The closest matching element; otherwise, null.

def closest(self, selector):
    ...
ParameterTypeDescription
selectorstrThe selector.

See Also