禁用右键单击特定的或class =“”

这是我的示例代码:

HTML

This is the Phone and NO ONE SHOULD RIGHT CLICK THIS! >:)




And this is the Keyboard, ofcourse yo can right click this :)

JS

 $('img').bind('contextmenu', function(e){ alert("This Logo is protected");return false; }); 

小提琴

我希望没有人能够右键单击第一张图片(手机),但除此之外(键盘)应该能够右键单击。

PS:我知道这可以被浏览器覆盖但是没关系:)

想出了解决方案。

 $('.tlClogo').bind('contextmenu', function(e) { return false; }); 

小提琴: http : //jsfiddle.net/79k52rvu/4/

编辑1:现在只有第一个不可右键点击!

   
This is the Phone and NO ONE SHOULD RIGHT CLICK THIS! >:)
And this is the Keyboard, ofcourse yo can right click this :)

编辑2:提供HTML-doc