JavaScript 中 getElementById 方法返回 null
<html>
<head>
<title>test_elementObject</title>
<script language="JavaScript" type="text/javascript">
<!--
var input1 = document.getElementById ( "input1" );
input1.value = "sample text"
//-->
</script>
</head>
<body>
<input id = "input1" type = "text" value = "" />
</body>
</html>
我是 JavaScript 新手,为什么脚本会导致错误:“input1 为空”?