UseQuerySelectorAll
katanakit-js / useQuerySelectorAll
Variable: useQuerySelectorAll
Section titled “Variable: 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.
Call Signature
Section titled “Call Signature”<K>(selector): HTMLElementTagNameMap[K][];Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends keyof HTMLElementTagNameMap |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
selector |
K |
Returns
Section titled “Returns”HTMLElementTagNameMap[K][]
Call Signature
Section titled “Call Signature”<E>(selector): E[];Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
E extends Element |
HTMLElement |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
selector |
string |
Returns
Section titled “Returns”E[]
Type Param
Section titled “Type Param”E
The expected Element subtype.
selector
A CSS selector string.
Returns
Section titled “Returns”An array of matching elements.
Example
Section titled “Example”const items = useQuerySelectorAll<HTMLLIElement>("li.item");items.forEach(el => console.log(el.textContent));