Skip to content

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')); // null

Signature:

function fish(selector: string): HTMLElement | null

Parameters:

ParameterTypeDescription
selectorstringThe 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