View Single Post
Old December 20th, 2004, 10:43 PM
lian_a lian_a is offline
Authorized User
Join Date: Apr 2004
Location: , , .
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default getElementByID error

Hi everyone! I am trying to study the getElementByID method. I came up with this simple code...

<title>Untitled Document</title>

function fnGetId(){
   // Returns the first DIV element in the collection.
   var oVDiv=document.getElementById("oDiv1");
    alert (oVDiv);

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<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()">


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!