JSFiddle - React, Tailwind, and code Playground
HTML
<div class="category" selected="false">First</div>
<div class="category" selected="false">Second</div>
<div id="tester" style="width: 100px; height: 100px; float: right; background-color: black;"></div>
JavaScript
$(".category").click(function()
{
$("#tester").css("background-color", "rgb(" + Math.floor(Math.random()*255) + "," + Math.floor(Math.random()*255) +"," + Math.floor(Math.random()*255) + ")");
$("#tester").append("<p>" + $(this).attr("selected") + "</p>");
if ($(this).attr("selected") == "true")
{
$(this).css("background-color", "transparent");
$(this).attr("selected", "false");
}
else if ($(this).attr("selected") == "false")
{
$(this).css("background-color", "blue");
$(this).attr("selected", "true");
}
});