这是我的简短 HTML 文档。
为什么 Chrome 控制台会注意到这个错误:
“未捕获的类型错误:无法调用“的方法‘appendChild’
null
?
<html>
<head>
<title>Javascript Tests</title>
<script type="text/javascript">
var mySpan = document.createElement("span");
mySpan.innerHTML = "This is my span!";
mySpan.style.color = "red";
document.body.appendChild(mySpan);
alert("Why does the span change after this alert? Not before?");
</script>
</head>
<body>
</body>
</html>