当有人使用右键单击尝试下载图像时,我想隐藏图库中的图像。当用户按普通左键单击时,使用 jquery 隐藏对象非常简单,只需添加一个简单的事件
$("document").ready(function(){
$("img").click(function(event){
$(this).hide("fast");
});
});
但是如何检测鼠标右键激活 event.preventDefault();
并设置 $(this).hide
对图像进行操作...
最佳答案
$("document").ready(function(){
$("img").click(function(event){
if(event.which === 3) {
$(this).hide("fast");
}
});
});
关于jquery - 使用jquery隐藏右键单击图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16309289/