Skip to content

findParent

findParent<T>(element, tag, classN): false | T

Defined in: core/dom/query.ts:50

Returns the closest ancestor with a given tag name and class name.

Starts at the parent, so the element itself is never returned. It takes one tag name and one class name, and both must match.

T extends Element = HTMLElement

Element

Element to start from.

string

Tag name, in upper case in HTML documents: 'DIV', not 'div'.

string

A single class name.

false | T

The ancestor, or false if there is none.

const carousel = findParent(slide, 'DIV', 'js-carousel-initialized');
if (carousel) {
// ...
}