var node = document.createTextNode('Hello World');
document.getElementById('main').appendChild(node);
I also want a <br /> between each Hello World
createTextNode is not allowing any html.
Any work around?
var node = document.createElement('div');
node.innerHTML = 'Hello World<br>';
document.documentElement.appendChild(node);
You can copy this code to your console and see the result immediately
<br>is an element, you'd usecreateElementto create elements, and elements can't exist inside textNodes, that's why they are called textnodes.