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 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    why does this not work?

    Hi

    I have the following at the top of the page

    Code:
    <script language="JavaScript">
    document.getElementById('form').style.display = 'none';
    </script>
    then a <div id='form'>contents</div> why does it not hide the div??

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,680
    Thanks
    0
    Thanked 230 Times in 225 Posts
    Hi there glenelkins,

    the div does not exist when the javascript is parsed.
    So try it like this...
    Code:
    
    <script type="text/javascript">
    window.onload=function() {
    document.getElementById('form').style.display='none';
     }
    </script>
    
    Also note that lanquage="javascript" is deprecated. Use type="text/javascript" instead.

    coothead


  •  

    Posting Permissions

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