JSFiddle - React, Tailwind, and code Playground

HTML

<div class="box" id="red"></div>

CSS

#red{
    width:100px;
    height:100px;
    background:red;
}
#blue{
    width:100px;
    height:100px;
    background:blue;
}

JavaScript

$(".box").click(function () {
    
    if($(this).attr("id") === "blue"){
        $(this).attr("id", "red"); 
    } else{
        
    $(this).attr("id", "blue");
        
    }
    
    
});