JSFiddle - React, Tailwind, and code Playground
by Zhuoyu Qian
HTML
<button id="replace">
replace
</button>
<div id="foo" contenteditable>
<h1> World</h1>
ff
</div>
JavaScript
replace.addEventListener('click', e=>{
foo.focus();
document.execCommand('selectAll');
document.execCommand('insertHTML',null, `<h1> World</h1>eer`);
});