Home } Navigation } Expanding Menu



This is a simple expanding menu. The anchor tags that expand each menu are added by JavaScript, so the HTML code doesn't contain any event handlers or unnecessary HTML tags. The structure of the menu is defined with unordered and ordered lists elements.

The JavaScript Source: Navigation : Expanding Menu

Simply click inside the window below, use your cursor to highlight the script, and copy [Control]+C the script into a new file in your text editor (such as Note Pad) and save [Control+S]. The script is yours!!!


Did you use this script?  Do you like this site?  Please link to us!

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

3. From: Teri
04/08/2009 22:14:25

Thanks for the script!

Any way to keep the menu expanded when a sub is clicked and the page changes?

2. From: Shana
04/08/2009 10:13:14

Rich,

you can fix that by changing the css,

in the menu style:

width: 100px;



either just delete the width or adjust to what you need

1. From: Rich Heyn
Travis Beckham's expanding menu code
12/15/2008 16:30:49

Good day,

I was able to use the code for my navigation needs so thank you.

The only issue I am having is figuring out how to adjust the length of the menu header and the menu sub headers. I'm very new to js and could use some guidence.

How do I make each line longer so it wont wrap to the next line. Here's an exapmle of a title I'm using, "Abbreviations Used in this Manual".

Currently, it comes out like this:

Abbreviations
Used in this
Manual

Thanks

Sign up for the JavaScript Weekly

internet.com Privacy Policy
We'll send this script to you!

(just click "Send it!" once!)

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs