Skip to content

Element.find method

Element › find

Official

Finds the first descendant element that matches the selector.

Signature:

find(selector: string): Element | null

Parameters:

Parameter Type Description
selector string The selector to find the element with.

Returns: Element | nullThe first descendant element that matches the selector, or null if no match is found.

Example:

const element = createEl('p');
element.createEl('strong', { cls: 'foo' });
console.log(element.find('.foo')); // <strong class="foo"></strong>
console.log(element.find('.bar')); // null