JSFiddle - React, Tailwind, and code Playground

by tea4two

HTML

<div class="first"></div>

CSS

.first {
    width: 100px;
    height: 100px;
    background: blue;
}
.first.red {
    background: red;
}

JavaScript

$(function() {
    var $obj = $('.first');
    $obj.addClass('red');
    if( $obj.hasClass('red') ) {
        console.log('ありまっせ');
    } else {
            console.log('ないでっせ');
        }
    
});