This example demonstrates how to create a multi-tiered menu using nothing but JavaScript.
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
constructor (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 addItem
,
insertItem
, or addItems
methods.
To add a submenu to a MenuItem via script, set the MenuItem instance's "submenu" configuration property to an object literal that specifies values for both the "id" and "itemdata" properties.
Finally, it is necessary to call the render
method passing
the id of, or reference to the element the Menu should be appended to.
Copyright © 2007 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings