JSFiddle - React, Tailwind, and code Playground

by john_s

HTML

<b>
    <input type="checkbox" value="" />
    I need replaced
</b>

JavaScript

var getNonEmptyChildTextNodes = function($element) {
    return $element.contents().filter(function() {
        return (this.nodeType == 3) && (this.textContent.trim() != '');
    });
};

getNonEmptyChildTextNodes($('b'))[0].textContent = 'new text';