JSFiddle - React, Tailwind, and code Playground

by James Connolly

HTML

<section class="target"></section>
<div>

</div>

JavaScript

// select the element that will be replaced
var el = document.querySelector('.target div');

// <a href="/javascript/manipulation/creating-a-dom-element-51/">create a new element</a> that will take the place of "el"
var newEl = document.createElement('p');
newEl.innerHTML = '<b>Hello World!</b>';

// replace el with newEL
el.parentNode.replaceChild(newEl, el);