Why is null returned by the getElementById method in JavaScript?
<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>
I am new to JavaScript and receiving an error: "input1 is null". Can someone help me understand why this is happening?