how to build innerHtml in javascript code example
Example 1: .innerhtml
// .innerHTML method is used to change the html contents of a DOM object
document.getElementById("demo").innerHTML = "Paragraph changed!";
Example 2: 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;
}