To get list of data-* attributes using JavaScript, we use the dataset
property.
For instance, we write
const attributes = element.dataset;
const cat = element.dataset.cat;
to get a list of data- attributes as an object with the element.dataset
property.
We use the element.dataset.cat
property to get the value of the element
‘s data-cat
attribute.