Skip to content
0

katanakit-js / useQuerySelector

Variable: useQuerySelector ​

ts
const useQuerySelector: {
<K>  (selector): HTMLElementTagNameMap[K] | null;
<E>  (selector): E | null;
};

Defined in: src/infrastructure/dom/dom.service.ts:112

Returns the first element matching a CSS selector.

Call Signature ​

ts
<K>(selector): HTMLElementTagNameMap[K] | null;

Type Parameters ​

Type Parameter
K extends keyof HTMLElementTagNameMap

Parameters ​

ParameterType
selectorK

Returns ​

HTMLElementTagNameMap[K] | null

Call Signature ​

ts
<E>(selector): E | null;

Type Parameters ​

Type ParameterDefault type
E extends ElementHTMLElement

Parameters ​

ParameterType
selectorstring

Returns ​

E | null

Type Param ​

E

The expected Element subtype.

Param ​

selector

A CSS selector string.

Returns ​

The matching element, or null.

Example ​

ts
const el = useQuerySelector<HTMLElement>(".my-class");

Released under the MIT License.