1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

ineffective getElementById in ie7

Discussion in 'JavaScript' started by progfrog, Jun 9, 2009.

  1. #1
    hello,I;'m trying to hide a DIV element without any success pls see if i got something here wrong because i just cant see it.
    10x.
    
    <script type="text/javascript">
     var P = document.getElementById('Funk');
     P.style.display='none'; </script>
    
    Code (markup):
    the div i'm trying to reace is this:
    
    
    <div id="Funk">
    <p> 
    HelloWorld
    </p>
    
    HTML:

     
    progfrog, Jun 9, 2009 IP
  2. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Hi progfrog,
    Nothing seems to be wrong with your code.
    May be you should include it in a function and call it on button click or onLoad event.
    Also check whether you have closed the div properly.

    Hope this helps.
     
    Unni krishnan, Jun 9, 2009 IP
  3. cc2365

    cc2365 Member

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    Well, if your script executed before the <div> element loaded, it won't work.
    You can try to wrap your code in a function, as Unni krishnan said:
    
    <script type="text/javascript">
     function hideDIV() {
      var P = document.getElementById('Funk');
      P.style.display='none';
     }
    </script>
    
    HTML:
    Put this between <head> and </head>. Then call this function after your <div> loaded. :)
     
    cc2365, Jun 10, 2009 IP