gpt4 book ai didi

javascript - 根据右键单击的 DOM 元素的 ID 创建动态菜单

转载 作者:行者123 更新时间:2023-11-30 06:26:01 24 4
gpt4 key购买 nike

我想根据右键单击的 DOM 元素的 ID 创建动态菜单。这样我就可以为特定用户显示菜单,例如:“Label For 23”

我正在使用类似这样的上下文菜单,

$.contextMenu({
selector: 'tr',
callback: function (key, options) {
var m = "clicked: " + key;
var temp = $(this);
if (key == "Rebate") DoInvoice();
},
items: {
"Credit Note": { name: "Credit Note " },
"Full Refund": { name: "Full Refund " },
"Partial Refund": { name: "Partial Refund " },
"Rebate": { name: "Rebate " }
}
});

目前我在右键单击时获得上下文菜单,如下图所示, enter image description here

但我想以这样的格式显示

"Credit Note For 130",
"Full Refund For 130",
"Partial Refund For 130",
"Rebate For 130"

请尽快帮助我。

最佳答案

试试这个:-

var userid;
// Get the ID, when rightclick event is fired & set the ID to above variable.

items: {
"Credit Note For"+ userid : { name: "Credit Note " },
"Full Refund For"+ userid : { name: "Full Refund " },
"Partial Refund For"+ userid : { name: "Partial Refund " },
"Rebate For"+ userid : { name: "Rebate " }
}

关于javascript - 根据右键单击的 DOM 元素的 ID 创建动态菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21038276/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com