Skip to content

UseGetElementByClass

katanakit-js / useGetElementByClass

function useGetElementByClass<T>(className): T | null;

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

Finds the first element matching a class name.

Type Parameter Default type Description
T extends HTMLElement HTMLElement The expected HTMLElement subtype.
Parameter Type Description
className string A class name, with or without a leading ..

T | null

The matching element, or null.

const card = useGetElementByClass(".card");
const card2 = useGetElementByClass("card"); // equivalent