JSFiddle - React, Tailwind, and code Playground

by Alexander Yankovoy

HTML

<div>This is some content.  <b>Other HTML should not be affected by manipulations</b></div>

CSS

span { color: red; font-weight: bold; }

JavaScript

(function () { 
    var node = $("div").contents().filter(function () { return this.nodeType == 3 }).first(),
        text = node.text(),
        first = text.slice(0, text.indexOf(" "));
    
    if (!node.length)
        return;
    
    node[0].nodeValue = text.slice(first.length);
    node.before('<span>' + first + '</span>');
})();