<div id="target"><span>あいうえお</span></div>
<br>
<div id="target2"><span>あいうえお</span></div>
let element = document.getElementById('target');
let element2 = document.getElementById('target2');
element.innerHTML = "";
element2.innerHTML = "<span>タグ付きで置き換え</span>";
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.