Answers for "javascript create node from innerhtml"

1

javascript create node from innerhtml

function createElement( str ) {
    var frag = document.createDocumentFragment();

    var elem = document.createElement('div');
    elem.innerHTML = str;

    while (elem.childNodes[0]) {
        frag.appendChild(elem.childNodes[0]);
    }
    return frag;
}
Posted by: Guest on March-02-2020
0

js create element innerhtml

function createElement( str ) {
    var frag = document.createDocumentFragment();

    var elem = document.createElement('div');
    elem.innerHTML = str;

    while (elem.childNodes[0]) {
        frag.appendChild(elem.childNodes[0]);
    }
    return frag;
}
Posted by: Guest on July-22-2021

Code answers related to "javascript create node from innerhtml"

Code answers related to "Javascript"

Browse Popular Code Answers by Language