Skip to content

UseQuerySelectorAll

katanakit-js / useQuerySelectorAll

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

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

Returns all elements matching a CSS selector.

<K>(selector): HTMLElementTagNameMap[K][];
Type Parameter
K extends keyof HTMLElementTagNameMap
Parameter Type
selector K

HTMLElementTagNameMap[K][]

<E>(selector): E[];
Type Parameter Default type
E extends Element HTMLElement
Parameter Type
selector string

E[]

E

The expected Element subtype.

selector

A CSS selector string.

An array of matching elements.

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