JSFiddle - React, Tailwind, and code Playground
HTML
<div error errDesc=" This is error">
a
</div>
<div >
b
</div>
<div>
c
</div>
<div error errDesc=" This is error">
d
</div>
JavaScript
// will give all the div
var a = Array.prototype.slice.call(document.querySelectorAll("div"))
a.forEach(function(item){
if(item.hasAttribute('error')){
console.log(item.getAttribute('errDesc'))
}
})