I want add an element with JavaScript.
I have the following 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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…