querySelector

fun Document.querySelector(selector: String, filter: (Element) -> Boolean = { true }): Element?

Gets the first element that matches the specified CSS selector.

Return

The first element that matches the selector, or null if it doesn't exist.

Parameters

selector

The CSS selector to match.

filter

An optional filter function to apply to the elements.


fun Element.querySelector(selector: String, filter: (Element) -> Boolean = { true }): Element?

Gets the first element that matches the specified CSS selector within the element.

Return

The first element that matches the selector, or null if it doesn't exist.

Parameters

selector

The CSS selector to match.

filter

An optional filter function to apply to the elements.