JSFiddle - React, Tailwind, and code Playground
HTML
<div customAttr="12" title="me"></div>
<div anotherAttr="Bear"></div>
<div yetAnotherAttr="Elephant"></div>
CSS
div{
width: 100px;
height: 100px;
background-color: red;
}
.selected{
background-color: green;
}
JavaScript
var m = /another/i;
$('div').each(function(){
var $this = $(this);
$.each(this.attributes,function(){
if (this.name.match(m)){
$this.addClass('selected');
$this.text(this.name + ' : ' + this.value); //or use its custom-attribute's value
}
});
});