Skip to content
0

katanakit-js / useQuerySelectorAll

Variable: useQuerySelectorAll ​

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

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

Returns all elements matching a CSS selector.

Call Signature ​

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

Type Parameters ​

Type Parameter
K extends keyof HTMLElementTagNameMap

Parameters ​

ParameterType
selectorK

Returns ​

HTMLElementTagNameMap[K][]

Call Signature ​

ts
<E>(selector): E[];

Type Parameters ​

Type ParameterDefault type
E extends ElementHTMLElement

Parameters ​

ParameterType
selectorstring

Returns ​

E[]

Type Param ​

E

The expected Element subtype.

Param ​

selector

A CSS selector string.

Returns ​

An array of matching elements.

Example ​

ts
const items = useQuerySelectorAll<HTMLLIElement>("li.item");
items.forEach(el => console.log(el.textContent));

Released under the MIT License.