# Example: Adding A Context Menu To A Table (YUI Library) [Examples Home]

When adding context menus to large data structures like a `<table>` or large list (`<ol>` or `<ul>`), it is recommended to bind a single YAHOO.widget.ContextMenu instance to the structure's root element, than to a set of its child nodes (`<tr>`s or `<li>`s). Doing so significantly improves the performance of a web page or application by reducing the number of "contextmenu" event handlers as well as the number of YAHOO.widget.ContextMenu instances in memory.

This example demonstrates this technique, as well as how to create a context-sensitive context menu; a context menu whose content changes based on the element that triggered its display.

Please Note: Opera users will need to do the following to use this example:

- Opera for Windows: Hold down the control key and click with the left mouse button.
- Opera for OS X: Hold down the command key (⌘) and click with the left mouse button.

Row 0, Column 1 | Row 0, Column 2 | Row 0, Column 3 | Row 0, Column 4
Row 1, Column 1 | Row 1, Column 2 | Row 1, Column 3 | Row 1, Column 4
Row 2, Column 1 | Row 2, Column 2 | Row 2, Column 3 | Row 2, Column 4
Row 3, Column 1 | Row 3, Column 2 | Row 3, Column 3 | Row 3, Column 4
Row 4, Column 1 | Row 4, Column 2 | Row 4, Column 3 | Row 4, Column 4
Row 5, Column 1 | Row 5, Column 2 | Row 5, Column 3 | Row 5, Column 4
Row 6, Column 1 | Row 6, Column 2 | Row 6, Column 3 | Row 6, Column 4
Row 7, Column 1 | Row 7, Column 2 | Row 7, Column 3 | Row 7, Column 4
Row 8, Column 1 | Row 8, Column 2 | Row 8, Column 3 | Row 8, Column 4
Row 9, Column 1 | Row 9, Column 2 | Row 9, Column 3 | Row 9, Column 4
Row 10, Column 1 | Row 10, Column 2 | Row 10, Column 3 | Row 10, Column 4
Row 11, Column 1 | Row 11, Column 2 | Row 11, Column 3 | Row 11, Column 4
Row 12, Column 1 | Row 12, Column 2 | Row 12, Column 3 | Row 12, Column 4
Row 13, Column 1 | Row 13, Column 2 | Row 13, Column 3 | Row 13, Column 4
Row 14, Column 1 | Row 14, Column 2 | Row 14, Column 3 | Row 14, Column 4
Row 15, Column 1 | Row 15, Column 2 | Row 15, Column 3 | Row 15, Column 4
Row 16, Column 1 | Row 16, Column 2 | Row 16, Column 3 | Row 16, Column 4
Row 17, Column 1 | Row 17, Column 2 | Row 17, Column 3 | Row 17, Column 4
Row 18, Column 1 | Row 18, Column 2 | Row 18, Column 3 | Row 18, Column 4
Row 19, Column 1 | Row 19, Column 2 | Row 19, Column 3 | Row 19, Column 4
Row 20, Column 1 | Row 20, Column 2 | Row 20, Column 3 | Row 20, Column 4
Row 21, Column 1 | Row 21, Column 2 | Row 21, Column 3 | Row 21, Column 4
Row 22, Column 1 | Row 22, Column 2 | Row 22, Column 3 | Row 22, Column 4
Row 23, Column 1 | Row 23, Column 2 | Row 23, Column 3 | Row 23, Column 4
Row 24, Column 1 | Row 24, Column 2 | Row 24, Column 3 | Row 24, Column 4
Row 25, Column 1 | Row 25, Column 2 | Row 25, Column 3 | Row 25, Column 4
Row 26, Column 1 | Row 26, Column 2 | Row 26, Column 3 | Row 26, Column 4
Row 27, Column 1 | Row 27, Column 2 | Row 27, Column 3 | Row 27, Column 4
Row 28, Column 1 | Row 28, Column 2 | Row 28, Column 3 | Row 28, Column 4
Row 29, Column 1 | Row 29, Column 2 | Row 29, Column 3 | Row 29, Column 4
Row 30, Column 1 | Row 30, Column 2 | Row 30, Column 3 | Row 30, Column 4
Row 31, Column 1 | Row 31, Column 2 | Row 31, Column 3 | Row 31, Column 4
Row 32, Column 1 | Row 32, Column 2 | Row 32, Column 3 | Row 32, Column 4
Row 33, Column 1 | Row 33, Column 2 | Row 33, Column 3 | Row 33, Column 4
Row 34, Column 1 | Row 34, Column 2 | Row 34, Column 3 | Row 34, Column 4
Row 35, Column 1 | Row 35, Column 2 | Row 35, Column 3 | Row 35, Column 4
Row 36, Column 1 | Row 36, Column 2 | Row 36, Column 3 | Row 36, Column 4
Row 37, Column 1 | Row 37, Column 2 | Row 37, Column 3 | Row 37, Column 4
Row 38, Column 1 | Row 38, Column 2 | Row 38, Column 3 | Row 38, Column 4
Row 39, Column 1 | Row 39, Column 2 | Row 39, Column 3 | Row 39, Column 4
Row 40, Column 1 | Row 40, Column 2 | Row 40, Column 3 | Row 40, Column 4
Row 41, Column 1 | Row 41, Column 2 | Row 41, Column 3 | Row 41, Column 4
Row 42, Column 1 | Row 42, Column 2 | Row 42, Column 3 | Row 42, Column 4
Row 43, Column 1 | Row 43, Column 2 | Row 43, Column 3 | Row 43, Column 4
Row 44, Column 1 | Row 44, Column 2 | Row 44, Column 3 | Row 44, Column 4
Row 45, Column 1 | Row 45, Column 2 | Row 45, Column 3 | Row 45, Column 4
Row 46, Column 1 | Row 46, Column 2 | Row 46, Column 3 | Row 46, Column 4
Row 47, Column 1 | Row 47, Column 2 | Row 47, Column 3 | Row 47, Column 4
Row 48, Column 1 | Row 48, Column 2 | Row 48, Column 3 | Row 48, Column 4
Row 49, Column 1 | Row 49, Column 2 | Row 49, Column 3 | Row 49, Column 4
Row 50, Column 1 | Row 50, Column 2 | Row 50, Column 3 | Row 50, Column 4
Row 51, Column 1 | Row 51, Column 2 | Row 51, Column 3 | Row 51, Column 4
Row 52, Column 1 | Row 52, Column 2 | Row 52, Column 3 | Row 52, Column 4
Row 53, Column 1 | Row 53, Column 2 | Row 53, Column 3 | Row 53, Column 4
Row 54, Column 1 | Row 54, Column 2 | Row 54, Column 3 | Row 54, Column 4
Row 55, Column 1 | Row 55, Column 2 | Row 55, Column 3 | Row 55, Column 4
Row 56, Column 1 | Row 56, Column 2 | Row 56, Column 3 | Row 56, Column 4
Row 57, Column 1 | Row 57, Column 2 | Row 57, Column 3 | Row 57, Column 4
Row 58, Column 1 | Row 58, Column 2 | Row 58, Column 3 | Row 58, Column 4
Row 59, Column 1 | Row 59, Column 2 | Row 59, Column 3 | Row 59, Column 4
Row 60, Column 1 | Row 60, Column 2 | Row 60, Column 3 | Row 60, Column 4
Row 61, Column 1 | Row 61, Column 2 | Row 61, Column 3 | Row 61, Column 4
Row 62, Column 1 | Row 62, Column 2 | Row 62, Column 3 | Row 62, Column 4
Row 63, Column 1 | Row 63, Column 2 | Row 63, Column 3 | Row 63, Column 4
Row 64, Column 1 | Row 64, Column 2 | Row 64, Column 3 | Row 64, Column 4
Row 65, Column 1 | Row 65, Column 2 | Row 65, Column 3 | Row 65, Column 4
Row 66, Column 1 | Row 66, Column 2 | Row 66, Column 3 | Row 66, Column 4
Row 67, Column 1 | Row 67, Column 2 | Row 67, Column 3 | Row 67, Column 4
Row 68, Column 1 | Row 68, Column 2 | Row 68, Column 3 | Row 68, Column 4
Row 69, Column 1 | Row 69, Column 2 | Row 69, Column 3 | Row 69, Column 4
Row 70, Column 1 | Row 70, Column 2 | Row 70, Column 3 | Row 70, Column 4
Row 71, Column 1 | Row 71, Column 2 | Row 71, Column 3 | Row 71, Column 4
Row 72, Column 1 | Row 72, Column 2 | Row 72, Column 3 | Row 72, Column 4
Row 73, Column 1 | Row 73, Column 2 | Row 73, Column 3 | Row 73, Column 4
Row 74, Column 1 | Row 74, Column 2 | Row 74, Column 3 | Row 74, Column 4
Row 75, Column 1 | Row 75, Column 2 | Row 75, Column 3 | Row 75, Column 4
Row 76, Column 1 | Row 76, Column 2 | Row 76, Column 3 | Row 76, Column 4
Row 77, Column 1 | Row 77, Column 2 | Row 77, Column 3 | Row 77, Column 4
Row 78, Column 1 | Row 78, Column 2 | Row 78, Column 3 | Row 78, Column 4
Row 79, Column 1 | Row 79, Column 2 | Row 79, Column 3 | Row 79, Column 4
Row 80, Column 1 | Row 80, Column 2 | Row 80, Column 3 | Row 80, Column 4
Row 81, Column 1 | Row 81, Column 2 | Row 81, Column 3 | Row 81, Column 4
Row 82, Column 1 | Row 82, Column 2 | Row 82, Column 3 | Row 82, Column 4
Row 83, Column 1 | Row 83, Column 2 | Row 83, Column 3 | Row 83, Column 4
Row 84, Column 1 | Row 84, Column 2 | Row 84, Column 3 | Row 84, Column 4
Row 85, Column 1 | Row 85, Column 2 | Row 85, Column 3 | Row 85, Column 4
Row 86, Column 1 | Row 86, Column 2 | Row 86, Column 3 | Row 86, Column 4
Row 87, Column 1 | Row 87, Column 2 | Row 87, Column 3 | Row 87, Column 4
Row 88, Column 1 | Row 88, Column 2 | Row 88, Column 3 | Row 88, Column 4
Row 89, Column 1 | Row 89, Column 2 | Row 89, Column 3 | Row 89, Column 4
Row 90, Column 1 | Row 90, Column 2 | Row 90, Column 3 | Row 90, Column 4
Row 91, Column 1 | Row 91, Column 2 | Row 91, Column 3 | Row 91, Column 4
Row 92, Column 1 | Row 92, Column 2 | Row 92, Column 3 | Row 92, Column 4
Row 93, Column 1 | Row 93, Column 2 | Row 93, Column 3 | Row 93, Column 4
Row 94, Column 1 | Row 94, Column 2 | Row 94, Column 3 | Row 94, Column 4
Row 95, Column 1 | Row 95, Column 2 | Row 95, Column 3 | Row 95, Column 4
Row 96, Column 1 | Row 96, Column 2 | Row 96, Column 3 | Row 96, Column 4
Row 97, Column 1 | Row 97, Column 2 | Row 97, Column 3 | Row 97, Column 4
Row 98, Column 1 | Row 98, Column 2 | Row 98, Column 3 | Row 98, Column 4
Row 99, Column 1 | Row 99, Column 2 | Row 99, Column 3 | Row 99, Column 4