📄 item-object.html
字号:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>dhtml menu javascript menu</title> <link rel="stylesheet" href="../code.css" /> </head> <body onload="window.parent.sectionLoaded(document.body)"><div style="font-size: 1px; line-height: 1px"><br /></div><h1>DynarchMenu.MenuItem -- the object</h1><!-- -*- nxml -*- --><p> When the action of some menu item involves calling a JavaScript function, that function can determine what the clicked item is. This helps having one handler for multiple actions, as you can learn in <a onclick="showSection('actions'); return false;" href="actions.html">menu actions documentation</a>. The MenuItem object provides methods and properties that allow one to investigate item properties or change its state, label, icon and so on.</p><h2>Determining the item</h2><p>Say we have the following menu:</p><pre> <<span class="function-name">ul</span> id=<span class="string">"menu"</span>> <<span class="function-name">li</span>><<span class="function-name">a</span> href=<span class="string">"javascript:retval = my_handler(this);"</span>>Item<<span class="function-name">/a</span>><<span class="function-name">/li</span>> <<span class="function-name">/ul</span>></pre><p> That's a very simple menu with one item. That item calls a function handler and assigns its value to <tt>retval</tt>; we'll talk about <tt>retval</tt> in a moment. The function handler can be written like this:</p><pre> function my_handler(action) { var menu_item = action.info; alert(menu_item.label); return false; }</pre><p> So, in order to retrieve the menu item just use the 鈥渋nfo鈥
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -