JSFiddle - React, Tailwind, and code Playground

by nevkatz

HTML

<div id="root">

</div>

JavaScript

let str = "&lt;p&gt;That&amp;#39;s right! Khady knows customers want to buy eggs and that no vendors offer them nearby.&lt;/p&gt;\n";

let root = document.querySelector('#root');




function print_sanitized(el, str) {
 let docfrag = document.createElement('div');

 docfrag.innerHTML = str;

 el.innerHTML = docfrag.textContent;

 return el;

}

print_sanitized(root, str);