Skip to content

Window.fish method

Window › fish

Official

Finds the first element that matches the selector.

Signature:

fish(selector: string): HTMLElement | null

Parameters:

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

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

Example:

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