JSFiddle - React, Tailwind, and code Playground
by stevea
HTML
<div id="box1"></div>
div id="box2" class="test"> </div>
JavaScript
$(function() {
$.fn.hasAttr = function(name) {
return this.attr(name) !== undefined;
};
if($("#box1").hasAttr("class")){
console.log("box1 has class");
if($("#box2").hasAttr("class")){
console.log("box2 has class");
});