closest

fun <T : HTMLElement> closest(selector: HtmlTagName<T>): T?(source)

Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise.

MDN Reference


fun <T : SVGElement> closest(selector: SvgTagName<T>): T?(source)
fun <T : MathMLElement> closest(selector: MathMLTagName<T>): T?(source)
fun closest(selector: String): Element?(source)