This example demonstrates how to title groups of MenuItem instances.
Note: By default clicking outside of a Menu instance will hide it. Additionally, MenuItem instances without a submenu or a URL to navigate to will hide their parent Menu instance when clicked. Click the "Show Menu" button below to make the Menu instance visible if it is hidden.
To create a Menu with no pre-existing markup on the page, call the Menu
YAHOO.widget.Menu) passing the id of the Menu
element to be created as the first argument.
Add items to a Menu instance via the
Items can be organized into groups by creating a multi-dimensional array
of YAHOO.widget.MenuItem configuration properties and passing it to the
addItems method. Add a title to each group via the
Finally, it is necessary to call the
render method passing
the id of, or reference to the element the Menu should be appended to.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.