JSFiddle - React, Tailwind, and code Playground

by mlms13

HTML

<button id="create">Create</button>
<button id="remove" disabled>Remove</button>

CSS

#box {
    background: #2ac;
    height: 32px;
    width: 32px;
}

JavaScript

var createBtn = document.getElementById('create'),
    removeBtn = document.getElementById('remove');

createBtn.onclick = function () {
    createBox();
    createBtn.disabled = true;
    removeBtn.disabled = false;
};
removeBtn.onclick = function () {
    removeBox();
    createBtn.disabled = false;
    removeBtn.disabled = true;
};

function createBox() {
    var box = document.createElement('div');
    box.setAttribute('id', 'box');
    document.body.appendChild(box);
}

function removeBox() {
    var box = document.getElementById('box');
    $(box).fadeOut(400, function () {
        $(this).remove();
    });
}