UseGetElementByClass
katanakit-js / useGetElementByClass
Function: useGetElementByClass()
Section titled “Function: useGetElementByClass()”function useGetElementByClass<T>(className): T | null;Defined in: infrastructure/dom/dom.service.ts:92
Finds the first element matching a class name.
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 |
|---|---|---|
className |
string |
A class name, with or without a leading .. |
Returns
Section titled “Returns”T | null
The matching element, or null.
Example
Section titled “Example”const card = useGetElementByClass(".card");const card2 = useGetElementByClass("card"); // equivalent