JSFiddle - React, Tailwind, and code Playground

HTML

<div class='snippet'>hello</div>

<br>

<div id='showhtml'></div>

JavaScript

var text_only = '&lt;div&gt;' + $('.snippet').text() + '&lt;/div&gt';


document.getElementById('showhtml').innerHTML = text_only;