JSFiddle - React, Tailwind, and code Playground

by Michel Penke

HTML

<div id="divA">Div test</div>

<button id="btnAdd">Add it</button>
<button id="btnRemove">Take Away</button>

CSS

div {
    width: 200px;
    transition: all .5s linear;
    background: red;
}

div:after {
    transition: all .5s linear;
    background: transparent;
    color: transparent;
    content: "Test";
}

.test{
     background: blue;
}

.test:after{
    background: #0c0;
    color: black;
}

JavaScript

$("#btnAdd").click(function() {
  $("#divA").addClass("test");
});

$("#btnRemove").click(function() {
  $("#divA").removeClass("test");
});