Skip to content
0

katanakit-js / useGetAttribute

Function: useGetAttribute() ​

ts
function useGetAttribute(target, attr): string | null;

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

Gets the value of an attribute from the target element.

Parameters ​

ParameterTypeDescription
targetstring | ElementA CSS selector string or an Element instance.
attrstringThe attribute name.

Returns ​

string | null

The attribute value, or null if not present or element not found.

Example ​

ts
const href = useGetAttribute("a.link", "href");

Released under the MIT License.