JSFiddle - React, Tailwind, and code Playground

by lollero

HTML

<button>Click</button>

<div></div>

CSS

div {
    display: none;
    background: #c2c2c2;
    width: 20px;
    height: 20px;
    border-radius: 20px;
    margin: 30px;
}

.active { box-shadow: 0 0 20px #444; }

JavaScript

var active = 0;

$('button').on("click", function() {

    active = !active ? 1 : 0,
    sh = active ?'show' : 'hide',
    changeClass = active ? 'addClass' : 'removeClass';

    $(this)
        [ changeClass ]( 'active' )
        .next()[ sh ]();
    
});