Edit this page

up.fragment up.fragment.closest(element, selector)
JavaScript function

Returns the first element that matches the selector by testing the element itself and traversing up through ancestors in element's layers.

up.fragment.closest() will only match elements in the same layer as the given element. To match ancestors regardless of layers, use up.element.closest().


Parameters

element Element

The element on which to start the search.

selector string

The CSS selector to match.

Return value

element The matching element.

Returns null or undefined if no element matches in the same layer.