Skip to content
0

katanakit-js / useGetDataAttribute

Function: useGetDataAttribute() ​

ts
function useGetDataAttribute(target, key): string | undefined;

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

Gets a data-* attribute value from the target element.

Parameters ​

ParameterTypeDescription
targetstring | HTMLElementA CSS selector string or an HTMLElement instance.
keystringThe data key (without the data- prefix).

Returns ​

string | undefined

The data attribute value, or undefined.

Example ​

ts
const id = useGetDataAttribute("tr.row", "userId");

Released under the MIT License.