UseGetElementById
katanakit-js / useGetElementById
Function: useGetElementById()
Section titled “Function: useGetElementById()”function useGetElementById<T>(id): T | null;Defined in: infrastructure/dom/dom.service.ts:74
Finds an element by its id attribute.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type | Description |
|---|---|---|
T extends HTMLElement |
HTMLElement |
The expected HTMLElement subtype. |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id |
string |
The element id (without #). |
Returns
Section titled “Returns”T | null
The matching element, or null.
Example
Section titled “Example”const btn = useGetElementById<HTMLButtonElement>("submit-btn");