Baseline Widely available
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
.
A DOMStringMap
.
<div>
<svg viewBox="0 0 120 30" xmlns="http://www.w3.org/2000/svg">
<text x="20" y="20" id="user" data-id="1234567890" data-user="carinaanand">
Carina Anand
</text>
</svg>
</div>
const el = document.querySelector("#user");
console.log(el.dataset.id); // "1234567890"
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3