JSFiddle - React, Tailwind, and code Playground

by j08691

HTML

<div id="container">
     <h1>Hi</h1>
     <h2 class="Hi">Test</h2>
Hi</div>

JavaScript

$("#container").contents().each(function () {
    if (this.nodeType === 3) this.nodeValue = $.trim($(this).text()).replace(/Hi/g, "Hello")
    if (this.nodeType === 1) $(this).html( $(this).html().replace(/Hi/g, "Hello") )
})