JSFiddle - React, Tailwind, and code Playground

by JeffC

HTML

<p id="test">test</p>

JavaScript

var parentId = "test";
var id = "test1";
setTimeout("InsertElement(parentId)", 100);
while (CheckExists(parentId)) {}
document.write(document.getElementById(id).tagName);

function CheckExists(id) {
    var e;
    try {
        e = document.getElementById(id);
    } finally {
        alert(e);
    }
}

function InsertElement(id) {
    var e = document.getElementById(id);
    var div = document.createElement("div");
    div.id = "test1";
    div.innerHTML = "test1";
    e.appendChild(div);
}