Expand /Collapse Menu -on page load I need the menu collapsed....

Discussion in 'JavaScript' started by Eskarina, Apr 9, 2007.

  1. #1
    Hi,

    could someone help me figureout how to have my menu in the collapsed state when the page loads please ?

    here is the javascript ...

    function toggleList(id){
    if(document.getElementById){
    var element = document.getElementById(id);
    if(element){
    element.style.display =(element.style.display == 'none')?'':'none';
    }}}


    ------------------------
    applied to ul div...

    <h2>Expand -Collapse</h2> <a href="javascript:toggleList('idname')">[+/-]</a></strong>
    <ul id="idname" style="display:block">
    <li><a href="#html" target="_self">Number One</a></li>
    <li><a href="amana.html" target="_self">Number 2</a></li>
    <li><a href="baumatic.html" target="_self">Number 3</a></li></ul>



    Which I found from here It's just what I was looking for except that I'd really like it to be in a collapsed state as default.

    Thanks in advance for any help I may get :)
     
    Eskarina, Apr 9, 2007 IP
  2. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #2
    change
    
    <h2>Expand -Collapse</h2> <a href="javascript:toggleList('idname')">[+/-]</a></strong>
    <ul id="idname" style="display:block">
    <li><a href="#html" target="_self">Number One</a></li>
    <li><a href="amana.html" target="_self">Number 2</a></li>
    <li><a href="baumatic.html" target="_self">Number 3</a></li></ul>
    
    Code (markup):
    to

    
    <h2>Expand -Collapse</h2> <a href="javascript:toggleList('idname')">[+/-]</a></strong>
    <ul id="idname" style="display:none;">
    <li><a href="#html" target="_self">Number One</a></li>
    <li><a href="amana.html" target="_self">Number 2</a></li>
    <li><a href="baumatic.html" target="_self">Number 3</a></li></ul>
    
    Code (markup):
     
    giraph, Apr 9, 2007 IP
    Eskarina likes this.
  3. Eskarina

    Eskarina Guest

    Messages:
    608
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks giraph :) that's great.

    I did mess about with those values but was stabbing in the dark as I don't even know the right terms to use.

    Thanks again ;)
     
    Eskarina, Apr 9, 2007 IP
  4. morgue

    morgue Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey, how would you make it start "collapsed"? :confused:
     
    morgue, Apr 22, 2007 IP
  5. morgue

    morgue Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Got it...
    didn't notice the style="display:none;">
     
    morgue, Apr 22, 2007 IP