UseQuerySelector
katanakit-js / useQuerySelector
Variable: useQuerySelector
Section titled “Variable: useQuerySelector”const useQuerySelector: { <K>(selector): HTMLElementTagNameMap[K] | null; <E>(selector): E | null;};Defined in: infrastructure/dom/dom.service.ts:112
Returns the first element matching a CSS selector.
Call Signature
Section titled “Call Signature”<K>(selector): HTMLElementTagNameMap[K] | null;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] | null
Call Signature
Section titled “Call Signature”<E>(selector): E | null;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 | null
Type Param
Section titled “Type Param”E
The expected Element subtype.
selector
A CSS selector string.
Returns
Section titled “Returns”The matching element, or null.
Example
Section titled “Example”const el = useQuerySelector<HTMLElement>(".my-class");