JSFiddle - React, Tailwind, and code Playground
by Sascha
HTML
<div class="class" data-mark-comp="comp1"
data-conf-property1="p1"
data-conf-property2="p2"
data-conf-property3="p3"></div>
JavaScript
$().ready(function() {
// create an empty configuration array
var conf= [];
// find all class elements; currently only accepting one element, otherwise "conf" would have to
// be multi-dimensional
$(".class").each(function() {
$.each(this.attributes, function() {
if (this.name.substring(0, 5)=='data-') {
// in case the element matches, add a new configuration item to the "conf" array
conf[this.name.substring(5)]= this.value;
}
});
});
console.log(conf);
});