SVGElement: dataset property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

The dataset read-only property of the SVGElement interface provides read/write access to custom data attributes (data-*) on elements. It exposes a map of strings (DOMStringMap) with an entry for each data-* attribute.

For more information on the behavior of dataset, see HTMLElement.dataset.

Value

Examples

html
Carina Anand
js
const el = document.querySelector("#user");

console.log(el.dataset.id); // "1234567890"

Specifications

Specification
HTML
# dom-dataset-dev

Browser compatibility

See also