Results 1 to 4 of 4

Thread: hiding divs

  1. #1
    Join Date
    Apr 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hiding divs

    Hey, i got a pretty simple script which hides divs when you click a link, but I wanted to make the divs be hidden as default.
    Here's the simple bit of code:

    function hideshow(which){
    if (!document.getElementById)
    return
    if (which.style.display=="block")
    which.style.display="none"
    else
    which.style.display="block"
    }


    I've tried changing the 'else' line:
    which.style.display="block" ==> to ==> which.style.display="none" but that has the undesirable effect of hiding it and not allowing it to be shown again.

    Any ideas?
    Tyvm in advance

  2. #2
    Join Date
    Apr 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    never mind, in the div that i wanted to hide by default i just put style="display:none" in the tag.
    I am silly lol

  3. #3
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Simply use this in the div:

    Code:
    <div style="display: none;">
    That will make the div hidden when the page loads.
    Hope this helps.

    //EDIT: Sorry, cross posted. Glad you figured it out though.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  4. #4
    Join Date
    Apr 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yer, i usually work it out for myself JUST AFTER i post lol.

Bookmarks

Posting Permissions

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