我正在尝试学习 JavaScript.. 我正在尝试遵循示例.. 我无法让这个 getElementById 正常工作......为什么它在警报框中说 Null 而不是实际段落?
<html>
<head>
<script type="text/javascript">
var x = document.getElementById('excitingText');
alert(x);
</script>
</head>
<body>
<h1>This is a header!</h1>
<p id="excitingText">
This is a paragraph! <em>Excitement</em>!
</p>
<p>
This is also a paragraph, but it is not nearly as exciting as the last one.
</p>
</body>
</html>