Skip to content
0

katanakit-js / useGetElementByClass

Function: useGetElementByClass() ​

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

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

Finds the first element matching a class name.

Type Parameters ​

Type ParameterDefault typeDescription
T extends HTMLElementHTMLElementThe expected HTMLElement subtype.

Parameters ​

ParameterTypeDescription
classNamestringA class name, with or without a leading ..

Returns ​

T | null

The matching element, or null.

Example ​

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

Released under the MIT License.