简体   繁体   English

如何将焦点设置到剑道菜单中的特定菜单项

[英]How to set focus to specific menu item in kendo menu

I would like to open specific menu item and set focus on keydown event. 我想打开特定的菜单项并将焦点设置在keydown事件上。

I can open kendo menu by following code but can't set focus over there. 我可以通过以下代码打开剑道菜单,但不能在那上面设置焦点。

Thanks is Advance ! 谢谢是前进!

  <ul id="menu"> <li> Test </li> <li> Master <ul id="ulMaster"> <li>County</li> <li>State</li> <li>City</li> </ul> </li> <li> Transaction <ul> <li> Service Order </li> <li> Technician Payment </li> </ul> </li> </ul> 

 document.body.onkeydown = function (e) {
                var event = e || window.event
                var key = e.charCode || e.keyCode;
                if (event.altKey) {
                switch (key) {
                        case 68: // D
                            $("#ulMaster").trigger("mouseover");
                            break;
                    }
                }

$("#menu").kendoMenu({});

You can attach an event handler to Menu select event like this: 您可以将事件处理程序附加到Menu select事件,如下所示:

$("#menu").onkeydown({ select: function (e) {
    console.log(e.item);
} });

You also get the menu item in the event argument. 您还可以在事件参数中获得菜单项。 All The Best . 祝一切顺利 。 Vote if your Code Working 如果您的代码有效,则投票

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM