JSFiddle - React, Tailwind, and code Playground
by Pav Ratra
HTML
<div class="container">
<p>
Some text and span here
<span>This is a span element</span>
<span>This is another span element</span>
</p>
<p>This is a span element <a href="span.html">Test</a></p>
</div>
CSS
.marked { font-weight:bold; color:blue; }
JavaScript
var str = "another";
var newhtml = $('.container').html().replace(str, '<span class="marked">' + str + '</span>');
$('.container').html(newhtml);
//or $('.container').html($('.container').html().replace(str, '<span class="marked">' + str + '</span>'));