[英]how to get parent and child text for the kendo menu in the select event
I am using kendo menu.For this I have parent level menu and for each I have sub items. 我正在使用剑道菜单。为此,我有父级菜单,每一个都有子项。 I want to get the parent item text and sub item text in the select event.
我想在select事件中获取父项文本和子项文本。
To get the parent text,I used "open" function,by this I am able to get parent text,but I want this in select event. 要获取父文本,我使用了“打开”功能,因此我可以获取父文本,但是我想在select事件中使用它。
$("#menu").kendoMenu({
open: function onOpen(e) {
parentText = $(e.item).children(".k-link").text();
},
});
If you only have parent and child (two levels menu) you can use as selector for the parent the CSS class k-state-active
This is a CSS class to add to each of the ancestors of the selected option. 如果只有父级和子级(两级菜单),则可以用作父级的选择器CSS类
k-state-active
这是一个CSS类,可添加到所选选项的每个祖先中。
Your code would be: 您的代码为:
select: function (e) {
var me = e.item;
console.log("me", $(child).find(".k-link").text());
var father = $(".k-state-active", this.element);
console.log("father", father.text().trim());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.