getElementByID error
Hi everyone! I am trying to study the getElementByID method. I came up with this simple code...
<html>
<head>
<title>Untitled Document</title>
<!--
<script>
function fnGetId(){
// Returns the first DIV element in the collection.
var oVDiv=document.getElementById("oDiv1");
alert (oVDiv);
}
</SCRIPT>
-->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" >
<DIV ID="oDiv1">Div #1</DIV>
<DIV ID="oDiv2">Div #2</DIV>
<DIV ID="oDiv3">Div #3</DIV>
<INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">
</body>
</html>
however, it won't work. I don't know what's wrong with it. There error I get says "Object expected." Can somebody help me please?? thanks!
|