JSFiddle - React, Tailwind, and code Playground

HTML

<div>some text</div>


I try to get like this:
<div><span style="color: red">text</span></div>

JavaScript

$(function(){
    $('div:contains("text")').each(function() {
        $(this).html($(this).html().replace(/(text)/g, '<span style="color:red;">\$1</span>'));
    });
});