JSFiddle - React, Tailwind, and code Playground

HTML

<html>
    <body>
        <div id="myDiv">
            <span class="aClass">This span is classy.</span>
            <div style="font-size: 2em;">
                This div has style.
                <span class="anotherClass">Lorem Ipsum.</span>
            </div> 
        </div>
        <a href="javascript:removeStuff($('#myDiv'));">Remove classes &amp; styles</a>
    </body>
</html>

CSS

.aClass {
    font-size: 0.75em;
}

.anotherClass {
    font-weight: bold;
    color: Fuchsia;
}

JavaScript

function removeStuff(elem) {
    elem.children().each(function() {
        if ($(this).children().length > 0) {
            $(this).removeClass();
            $(this).removeAttr('style');
            removeStuff($(this));
        } else {
            $(this).removeClass();
            $(this).removeAttr('style');
        }
    });
}