JSFiddle - React, Tailwind, and code Playground

by Ryan Mitchell

HTML

<div id="content">This has content, along with <span>a span with content.</div>
    <button id="changeIt">Replace the above.</button>

JavaScript

$("#changeIt").click(function() {
    $("#content").contents().each(function() {
        if(this.nodeType == 3) {
            var text = $(this).text();
            text.replace("content", "*******");
            $(this).replaceWith(text);
        }
    });
});