JSFiddle - React, Tailwind, and code Playground

by Jake Overall

HTML

<div id="box" class="box"></div>
<div id="box2" class="box"></div>

CSS

.box{
    background-color: yellow;
    height: 100px;
    width: 100px;
}

JavaScript

function fade(id) {
    var dom = document.getElementById(id),
        level = 1;

    function step() {
        var h = level.toString(16);
        dom.style.backgroundColor = '#FFFF' + h + h;
        if (level < 15) {
            level += 1;
            setTimeout(step, 100);
        }
    }
    setTimeout(step, 100);
}

fade('box');
fade('box2');