JSFiddle - React, Tailwind, and code Playground

HTML

<div>
    blah 1
    <p>
        blah blah 1
    </p>
    <p>
        <span>blah blah blah 1</span> another 1
    </p>
</div>

CSS

p {
    background: #eee;
}
span {
    background: yellow;
}

JavaScript

function recursiveReplace(node) {
    if (node.nodeType == 3) { // text node
        node.nodeValue = node.nodeValue.replace("1", "۱");
        return;
    }

    if (node.nodeType == 1) { // element
        $(node).contents().each(function () {
            recursiveReplace(this);
        });
    }
}

recursiveReplace(document.body);