Skip to content

Conversation

@sjorsdonkers
Copy link
Contributor

The closest() method of the Element interface traverses the element and its parents (heading toward the document root) until it finds a node that matches the specified CSS selector.
Returns the closest ancestor Element or itself, which matches the selectors. If there are no such element, null.

Docs: https://developer.mozilla.org/en-US/docs/Web/API/Element/closest

@karlseguin karlseguin merged commit 35bff8c into main May 13, 2025
9 checks passed
@karlseguin karlseguin deleted the element_closest branch May 13, 2025 08:40
@github-actions github-actions bot locked and limited conversation to collaborators May 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants