JSFiddle - React, Tailwind, and code Playground

by Graham Fairweather

HTML

<div id="theDiv" class="bold red">Bold and red</div>
<button id="button">Remove red</button>

CSS

.bold {
    font-weight: bold
}
.red {
    background: red
}

JavaScript

var theDiv = document.getElementById("theDiv");
var button = document.getElementById("button");

function removeRed() {
    var classContent = theDiv.className;

    theDiv.className = classContent.replace("red", "").trim();
}

button.addEventListener("click", removeRed, false);