I want add element with JS. I have code:
var collection = document.getElementsByTagName('body');
var a = document.createElement('div');
a.innerHTML = 'some text';
collection.item(0).firstChild.appendChild(a);
and simple HTML:
<html>
<head>
</head>
<body>
</body>
</html>
Where is mistake?