Element dataset functionality
The dataset property on the HTMLElement interface provides read/write access to all the custom data attributes (data-*
) set on the element. This access is available both in HTML and within the DOM. It is a StringMap
, one entry for each custom data attribute. Note that the dataset property itself can be read, but not directly written. Instead, all writes must be to the individual properties within the dataset, which in turn represent the data attributes. Note also that an HTML data-attribute and its corresponding DOM dataset.property do not share the same name, but they are always similar.
Read more here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset