Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    <DIV> tag has no properties?

    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

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder
    Join Date
    Jun 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    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.

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ...and the price wasn't bad, either.

    Superb read:

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •