show element's "data-xxx" attribute compared with its `dataset` property.
Last updated 3 years ago
Was this helpful?
🔰 JS ⟩ DOM ⟩ Types ⟩ Element ⟩
// ⭐️ elem.showDataAttr('data-xxx') // show element's "data-xxx" attribute & property Element.prototype.showDataAttr = function (dataAttr){ const prop = dataAttr.toDatasetPropName(); log(`${this.nodeName.toLowerCase
String ⟩ .toDatasetPropName() - "data-xxx" attribute name to "dataset" property name.
Element ⟩ .attr() - get element's attribute
codepen ⟩ data attributes
"data-xxx" Attributes
CSS Properties