UseGetDataAttribute
katanakit-js / useGetDataAttribute
Function: useGetDataAttribute()
Section titled “Function: useGetDataAttribute()”function useGetDataAttribute(target, key): string | undefined;Defined in: infrastructure/dom/dom.service.ts:317
Gets a data-* attribute value from the target element.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
target |
string | HTMLElement |
A CSS selector string or an HTMLElement instance. |
key |
string |
The data key (without the data- prefix). |
Returns
Section titled “Returns”string | undefined
The data attribute value, or undefined.
Example
Section titled “Example”const id = useGetDataAttribute("tr.row", "userId");