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 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.