...

View Full Version : <DIV> tag has no properties?



frodo444
06-07-2003, 02:50 AM
I'm trying to make a section of code within a <div> tag appear when I click or MouseOver a button. I have something like this for my code.

<html>
<head>
<style ...>
#hd {...;visibility: hidden}
</style>
</head>
<body>
...
<input type="button" onMouseOver="document.HiddenDiv.style.visibility='visible'" onMouseOut="document.HiddenDiv.style.visibility='hidden'">
<div id="hd" name="HiddenDiv">
...
</div>

When I run it in either Netscape7 or IE5 I get a message saying that document.HiddenDiv has no properties, which I assume means that JS isn't recognizing it as the name of an HTML tag. I was wondering how I might go about doing this, because I am completely baffled and have tried everything else.

Thanks,
Eric

cheesebagpipe
06-07-2003, 02:58 AM
You're using an older style of object referencing (DOM 0); this isn't only inadvisable, but it never worked with elements like a div (only named images, forms, etc.). ID your elements:

<div id="hd">


...and:

onMouseOver="document.getElementById('hd').style.visibility='visible'

Just fyi: once your HTML has been parsed (read), you deal with objects/properties, not 'tags'. Helps to think of it this way.

frodo444
06-07-2003, 03:07 AM
Thank you very much for your help... can't believe I just got this answer in 10 minutes after searching for about 2 days.

Thanks,
Eric

PS: Gotta comment on how fast the reply was. Thanx.

cheesebagpipe
06-07-2003, 03:11 AM
...and the price wasn't bad, either. :D

Superb read:

http://www.brainjar.com/dhtml/intro/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum