JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Example</title>
</head>
<body>
<button id='btnAddClass'>Add class</button>
<button id='btnRemoveClass'>Remove class</button>
</body>
</html>
CSS
.blue {
color: blue;
}
JavaScript
const btnAddClass = document.getElementById('btnAddClass');
const btnRemoveClass = document.getElementById('btnRemoveClass');
btnAddClass.addEventListener('click', (e) => {
btnAddClass.classList.add('blue');
});
btnRemoveClass.addEventListener('click', (e) => {
btnAddClass.classList.remove('blue');
});