JSFiddle - React, Tailwind, and code Playground

HTML

<div id="foo">yyy<span>xxx</span></div>

JavaScript

$('#foo').html($('#foo').html().replace('yyy','')).find('span').before('new content')