JSFiddle - React, Tailwind, and code Playground
by _abl
HTML
<div></div>
CSS
div {
height:100px;
width:100px;
}
JavaScript
$("div").attr("data-color", "F0F0F0");
paintBackground();
$(document).click(function(){
makeDivDarker();
});
function makeDivDarker(){
$div = $("div");
var currentColor = parseInt($div.attr("data-color"), 16);
var newColor = currentColor - parseInt("101010", 16);
$div.attr("data-color", newColor.toString(16));
paintBackground();
}
function paintBackground(){
var $div = $("div");
$div.css("background-color", "#" + $div.attr("data-color"));
}