Accordion Menu

Skins




Expand Mode




Demo

Thanks for using Menucool Accordion Menu

The download package contains the source code and three skins.

Features

HTML

Click here to view the demo's HTML code.

The menu is typically structured using nested <UL> elements, allowing unlimited submenu levels.

JavaScript

Adjust the options in accordion-menu.js as needed to configure the menu's behavior.

var amenuOptions =
{
    menuId: "accordion",
    linkIdForDataSource: null,
    expand: "single", //"single", "multiple", "all" or "alltop"
    animation: 150,
};
var amenu = new McAcdnMenu(amenuOptions);
// If you need to dynamically build the menu, you can remove the above line, and add it to the place when it is ready to run.
linkIdForDataSource:  (default null).

If your site is a static HTML site, and you want to maintain your website menu in a separate file, set linkIdForDataSource to the ID of a link that points to the external markup file.

Example:

<a id="myMenuLink" href="res/amenu-markup.txt">Menu</a> Then set linkIdForDataSource: "myMenuLink" in the options.

With this setting, the script loads the menu markup from the linked file and renders the menu in place of the link (the link itself will be hidden).

expand mode:   "single", "multiple", "all" or "alltop"
  • single: Only one item can be expanded at a time. Expanding a new item automatically collapses other expanded ones.
  • multiple: Allows multiple items to be expanded at the same time.
  • all: Same as "multiple", but all submenu sections are expanded when the page loads.
  • alltop: Similar to "all", but only the top-level submenu sections are expanded on page load; deeper levels remain collapsed.

Built-in Functions

Sometimes you may need to control which menu item is active programmatically, such as when:

In these situations, you can use the following built-in functions:

Styles

The stylesheet is included in the download package.

Note: the last section of the CSS is for the content container. If you are using the accordion solely as a menu, that section can be safely removed.