Skip to content

UseGetDataAttribute

katanakit-js / useGetDataAttribute

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

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

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

Parameter Type Description
target string | HTMLElement A CSS selector string or an HTMLElement instance.
key string The data key (without the data- prefix).

string | undefined

The data attribute value, or undefined.

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