gpt4 book ai didi

Jquery 单元格左键单击事件

转载 作者:行者123 更新时间:2023-12-01 04:59:19 24 4
gpt4 key购买 nike

示例代码:简单的上下文菜单

右键单击链接后会弹出此弹出窗口。但单击网站中的任何单元格后希望获得相同的结果。

$(function(){
$.contextMenu({
selector: '.context-menu-one',
callback: function(key, options) {
var m = "clicked: " + key;
window.console && console.log(m) || alert(m);
},
items: {
"edit": {name: "Edit", icon: "edit"},
"cut": {name: "Cut", icon: "cut"},
"copy": {name: "Copy", icon: "copy"},
"paste": {name: "Paste", icon: "paste"},
"delete": {name: "Delete", icon: "delete"},
"sep1": "---------",
"quit": {name: "Quit", icon: "quit"}
}
});

$('.context-menu-one').on('click', function(e){
console.log('clicked', this);
})
});

<div class="context-menu-one box menu-1">
<strong>right click me</strong>
</div>

最佳答案

要让脚本在整个页面上触发,请更改选择器:

selector: 'body',

关于Jquery 单元格左键单击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11650271/

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