JSFiddle - React, Tailwind, and code Playground

HTML

<div id="mydiv">

</div>

JavaScript

String.prototype.text=function(){
return this ? String(this).replace(/<[^>]+>/gm, '') : '';
}

$("#mydiv").text("<span>My text</span>".text());