Element.Closest

Element.Closest method

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

public Element Closest(string selector)
ParameterTypeDescription
selectorStringThe selector.

Return Value

The closest matching element; otherwise, null.

See Also