JQuery_ Novice to Ninja - Earle Castledine [58]
Expandable/Collapsible Menus
A common feature of vertical site navigation is a submenu system, where links are grouped into similar categories. This makes it easy for the user to find relevant information and, by allowing the top-level categories to be expanded and collapsed, lets us store a large amount of information in a relatively small area. It also looks cool when menus slide open and close shut. A simple and effective expandable menu is very easy to set up; in fact, we learned most of the code required for a menu way back in Chapter 2. We’ll start by creating a simple menu, and then add a few extra features to it. Our initial menu will look like the one in Figure 5.1.
Figure 5.1. Expandable menus
These days (and until the HTML 5 navigation tag becomes standard) almost all navigational controls are created using unordered lists. From a semantic standpoint this is perfectly sensible, after all, a navigation menu is just a list of links. For our expandable menu, we’ll start off with a set of nested lists:
chapter_05/01_expandable_menus/index.html (excerpt)