Skip to content
0

katanakit-js / useGetElementById

Function: useGetElementById() ​

ts
function useGetElementById<T>(id): T | null;

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

Finds an element by its id attribute.

Type Parameters ​

Type ParameterDefault typeDescription
T extends HTMLElementHTMLElementThe expected HTMLElement subtype.

Parameters ​

ParameterTypeDescription
idstringThe element id (without #).

Returns ​

T | null

The matching element, or null.

Example ​

ts
const btn = useGetElementById<HTMLButtonElement>("submit-btn");

Released under the MIT License.