NameSilo

JavaScript Expand/Collapse

Located in Source Code, started by Jamison54, Jan 30, 2005

Replies:
1
Views:
61,904

  1. Jamison54

    Jamison54 Established Member ★★★★★★★★★★

    Posts:
    316
    Likes Received:
    2
    Hi all!

    If your in need of a simple script to have an expandable/collapsable menu, use my script:
    HTML:
    <script langauge="JavaScript" type="text/javascript">
    function doMenu(item) {
     obj=document.getElementById(item);
     col=document.getElementById("x" + item);
     if (obj.style.display=="none") {
      obj.style.display="block";
      col.innerHTML="[-]";
     }
     else {
      obj.style.display="none";
      col.innerHTML="[+]";
     }
    }
    </script>
    Then just layout a simple div:
    HTML:
    <a href="JavaScript:doMenu('main');" id=xmain>[+]</a> Main Item
    <div id=main style="margin-left:1em">
     <a href=#>Item 1</a><br>
     <a href=#>Item 2</a><br>
     <a href=#>Item 3</a>
    </div>
    <br>
    This should work in Internet Explorer 4.x+ and Firefox but you'll have to do a few checks to make it Netscape compatiable (which im not gonna explain).
     
    The views expressed on this page by users and staff are their own, not those of NamePros.
  2. hasif

    hasif Account Closed

    Posts:
    281
    Likes Received:
    0
    i was looking for this for my download zone website, i will use it as microsoft download senter used.
     

Want to reply or ask your own question?

It only takes a minute to sign up – and it's free!
biix
  1. NamePros uses cookies and similar technologies. By using this site, you are agreeing to our privacy policy, terms, and use of cookies.
    Dismiss Notice
Loading...