This example demonstrates how to create a multi-tiered menu using existing markup on the page.
Note: By default clicking outside of a menu will hide it. Additionally, menu items without a submenu or a URL to navigate will hide their parent menu when clicked. Click the "Show Menu" button below to make the menu visible if it is hidden.
The markup for a Menu control follows that of
YAHOO.widget.Module, with its body element
(<div class="bd"/>
) containing a list element
(<ul/>
).
Each item in a Menu is represented by a list item element
(<li class="yuimenuitem"/>
), each of which has a
label (<a class="yuimenuitemlabel"/>
) that can
contain plain text or HTML.
In addition to a label, each item in a Menu can also have a submenu. A
submenu can be added to a Menu item by nesting a Menu element inside
its root (<li class="yuimenuitem"/>
) element.
To instantiate a Menu, pass the id of its corresponding HTML element
(in this case "basicmenu") to the Menu constructor
(YAHOO.widget.Menu
). Once instantiated, it is necessary to
call the render
method. If you are creating a Menu from
markup that exists in the page you call render
with
no arguments.
Copyright © 2007 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings