JSFiddle - React, Tailwind, and code Playground
by jfriend00
HTML
<button id="fade">Fade</button>
<div id="box"></div>
CSS
#box {
background-color: red;
height: 100px;
width: 100px;
}
JavaScript
$("#fade").click(function() {
var target = 0.1;
var item = $("#box");
if (item.css("opacity") < 1) {
target = 1;
}
item.stop(true).animate({"opacity": target}, 1000);
});