JSFiddle - React, Tailwind, and code Playground

by charlescarver

HTML

<div class="parent">
    <div class="second">
        <div class="third">
            <ul>
                <li>Hi</li>
            </ul>
        </div>
    </div>
</div>
<div class="parent">
    <div class="second">
        <div class="third">
            <ul>
                <li>Hi</li>
            </ul>
        </div>
    </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 parents = $("body").children();
var i = 0;
function loop(){
    
    
    var children = $(parents[i]).find("*");
    var x = children.length;
    function inside(){
        $(children[x]).remove();
        i--;
        if (x > -1) {
            setTimeout(loop, 1000);
        }
    }
    inside();
    
    
    
    

    i++;
    if (i < parents.length) {
        setTimeout(loop, 0);
    }
}
loop();