且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CKEditor - 单击上下文菜单后获取元素

更新时间:2023-12-06 09:35:52

解决方案非常简单。

$('body').on('contextmenu','img',function(){
var imgid = $(this).attr('id');
alert(imgid);
})

使用jquery要跟踪点击图片,我们可以将它的id保存到全局变量。然后,在插件的命令中,获取我们之前保存的id。

Using jquery to track click on image, we can save it's id to global variable. Then, inside the command of the plugin, to take the id that we saved before.