I am a bit confused here. I was trying to do some basic DOM manipulation - testing it with appending a title to the <head>
tag. This is what I wrote:
document.head.appendChild(document.createElement("title").appendChild(document.createTextNode("Test Title")));
However, the above doesn't work. If I split it up, it works:
var node = document.createElement("title");
var text = document.createTextNode("Test title");
node.appendChild(text);
document.head.appendChild(node);
Why is that, what am I missing?