JSFiddle - React, Tailwind, and code Playground

by thecodeparadox

HTML

<div id="test" class="hasid">
    This is test div
    <div>
        parent div without id and class
    </div>
</div>
<div class="hasclass">
    has class but not id
</div>
<div id="hasid">
    has id but not class
</div>

CSS

.wrapped {
    color: #f00;
}

JavaScript

var divs = $('div:not([id][class])'); // select div if id or class either one is absense

//$('div:not([id][class])') // select div if id or class either one is absense
    
//$('div:not([id],[class])') // select div with no id and class


divs.each(function(index, val) {
    return $(val).addClass('wrapped');
});


console.log($('div[class]:not([id])'));