Why I getting error in browser?
TypeError: document.body is null
Code is working well in JSfiddle.
HTML
<head>
<meta charset="UTF-8">
<title></title>
<script src="jsscript.js"></script>
</head>
<body>
</body>
JS
var creElem = document.createElement("p");
creElem.innerHTML = "Hellow World";
creElem.setAttribute("id", "id_name");
document.body.appendChild(creElem);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…