JSFiddle - React, Tailwind, and code Playground
by Santosh Thakur
HTML
<div>Blue</div>
<div>Orange</div>
<div>Red</div>
CSS
div {
font-size:12px;
font-family:Arial;
padding:5px;
border:1px solid #ccc;
margin-bottom:4px;
}
JavaScript
(function () {
$('div').click(function () {
$(this).each(function () {
if ($(this).html() == 'Blue') {
$(this).css("background-color", "blue");
alert($(this).css("background-color"));
if ($(this).css("background-color") === "rgb(0, 0, 255)") {
alert(0);
} else {
$(this).css('background', 'white');
}
}
if ($(this).html() == 'Orange') {
$(this).css('background', 'orange');
}
if ($(this).html() == 'Red') {
$(this).css('background', 'red');
}
});
});
})();