Skip to content

UseGetElementById

katanakit-js / useGetElementById

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

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

Finds an element by its id attribute.

Type Parameter Default type Description
T extends HTMLElement HTMLElement The expected HTMLElement subtype.
Parameter Type Description
id string The element id (without #).

T | null

The matching element, or null.

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