JSFiddle - React, Tailwind, and code Playground
HTML
<div id='universals' data-path='/zz/' data-foodata-load='1'></div>
CSS
textarea { height: 100px }
JavaScript
// Reference to our element
var element = document.getElementById("universals"), attr;
// Cycle over each attribute on the element
for (var i = 0; i < element.attributes.length; i++) {
// Store reference to current attr
attr = element.attributes[i];
// If attribute nodeName starts with 'data-'
if (/^data-/.test(attr.nodeName)) {
// Log its name (minus the 'data-' part), and its value
console.log(
"Key: " + attr.nodeName.replace(/^data-/, ''),
"Val: " + attr.nodeValue
);
}
}