Jump to content

Javascript Expandable Menu


jwenzel
 Share

Recommended Posts

I have this expandable javascript menu I made, but I've got a problem. When the page loads, all of the links are expanded. I can not for the life of me figure out how to have the links collapsed on load. Any help here would be great.Thanks,

<a href="java script:switchit('links')">Links</a><br /><li id="links">  <a href="link/">Link 1</a><br /><a href="link">LInk 2</a></li><script type="text/javascript">function switchit(list){var listElementStyle=document.getElementById(list).style;if (listElementStyle.display=="none"){listElementStyle.display="block";}else {listElementStyle.display="none";}}</script>

Link to comment
Share on other sites

You could style #links as display:none initially - just add #links { display:none; } to your CSS.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...