Element.find method
Element › find
Official
Finds the first descendant element that matches the selector.Signature:
find(selector: string): Element | nullParameters:
| Parameter | Type | Description |
|---|---|---|
| selector | string | The selector to find the element with. |
Returns: Element | null — The 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