JSFiddle - React, Tailwind, and code Playground

by stecb

HTML

<div>
        <div>
            <p>
               <h1>
                 <a>lollypops</a>
               </h1>
            </p>
            <span>lollypops</span>
        </div>
    </div>
    <p>
       <span class="lollypops">Hello, World!</span>
       <img src="/lollypops.jpg" alt="Cool image" />
    </p>

JavaScript

$(document.body).find('*').each(function() {
    var tmp = $(this).children().remove();
    var text = $(this).text();
    text = text.replace(/lollypops/g, "marshmellows");
    $(this).text(text);
    $(this).append(tmp);
});