JSFiddle - React, Tailwind, and code Playground

by charlescarver

HTML

<div class="parent">
    <div class="second">Child 1</div>
    <div class="second">Child 2</div>
    <div class="third">
        <ul>Child 3</ul>
        <ul>Child 4</ul>
    </div>
</div>

CSS

.parent {
    background-color:red;
    padding:20px;
}
.second {
    background-color:blue;
    padding:20px;
}
.third {
    background-color:green;
    padding:20px;
}
ul {
    background-color:orange;
    padding:20px;
}
li {
    background-color:pink;
    padding:20px;
}

JavaScript

var nodes = [],
i = 0;

$('body').children().each(function() {
    // child nodes are added in reverse
    [].push.apply(nodes, $('*', this).get().reverse());
    // add parent
    nodes.push(this);
});

function loop() 
{
    $(nodes[i]).remove();
    if (++i < nodes.length) {
        setTimeout(loop, 1000);
    }
}

loop();