Edit this page

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

This feature has been deprecated. Use Element#closest() instead.

Load unpoly-migrate.js to polyfill deprecated features.

Returns the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.


Parameters

element
required

The element on which to start the search.

selector
required

The CSS selector to match.

string

Return value

element The matching element.

Returns null or undefined if no element matches.