Here is my simple HTML:
Hello World!
Here is
.appendChild() is a plain JavaScript method, not jQuery. The jQuery method is .append().
newDiv.append(newSpan);
$( myDOMElement ).append(newDiv);
Use .append()
newDiv.append(newSpan);
.appendChild() works with DOM element. newDiv is jQuery Object not a plain JavaScript DOM element.
Working Fiddle
newDiv is a jQuery object, not a DOM object.
jQuery objects do not have an appendChild method, they have an append method.