add innerhtml to div code example

Example 1: jquery add div element

$('#someParent').append('<div>I am new here</div>');

Example 2: JavaScript append text to div

var div = document.getElementById('myElementID');
div.innerHTML += "Here is some more data appended";

Example 3: 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;
}