fish
Official
Finds the first element that matches the selector.
Example:
function element = document.body.createEl('p');element.createEl('strong', { cls: 'foo' });console.log(fish('.foo')); // <strong class="foo"></span>console.log(fish('.bar')); // nullSignature:
function fish(selector: string): HTMLElement | nullParameters:
| Parameter | Type | Description |
|---|---|---|
selector | string | The selector to find the element with. |
Returns: HTMLElement | null — The first element that matches the selector, or null if no match is found.
Example:
function element = document.body.createEl('p');element.createEl('strong', { cls: 'foo' });console.log(fish('.foo')); // <strong class="foo"></span>console.log(fish('.bar')); // null