JSFiddle - React, Tailwind, and code Playground

HTML

<div id="main">
    abcabc
    <p class="a">def</p>
    <p class="b">abc</p>
</div>

CSS

body {color: red;}
p.a {color: blue;}
p.b {color: green;}

JavaScript

$('#main, #main *').contents().each(function() {
    if (this.nodeType == 3)
        this.nodeValue = this.nodeValue.replace(/a/g, 'z');
});