JSFiddle - React, Tailwind, and code Playground

by docluv

JavaScript

function createFragment(htmlStr) {
    var frag = document.createDocumentFragment(),
        temp = document.createElement('div');
    temp.innerHTML = htmlStr;
    while (temp.firstChild) {
        frag.appendChild(temp.firstChild);
    }
    return frag;
}

function appendChild(htmlStr) {

    // You can use native DOM methods to insert the fragment:
    document.body.appendChild(createFragment(htmlStr));
}


var str = '<div>Hello!</div><p>...</p>';