gpt4 book ai didi

javascript - 禁用右键单击特定
或类 =""

转载 作者:行者123 更新时间:2023-12-01 06:12:56 25 4
gpt4 key购买 nike

这是我的示例代码:

html

<div>
This is the Phone and NO ONE SHOULD RIGHT CLICK THIS! >:) </br>
<img class="tlClogo" src="http://i.imgur.com/0atiS5C.jpg" style="height: 120px; width:120px;">
</div></br></br></br></br>
And this is the Keyboard, ofcourse yo can right click this :)</br>
<img src="http://i.imgur.com/xkrKz1X.jpg" style="height: 120px; width:120px;">

js

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

fiddle

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

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

最佳答案

想出了一个解决方案。

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

fiddle :http://jsfiddle.net/79k52rvu/4/

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

<html>
<body>
<div>
This is the Phone and NO ONE SHOULD RIGHT CLICK THIS! >:) </br>
<img class="tlClogo" src="http://i.imgur.com/0atiS5C.jpg" style="height: 120px; width:120px;">
</div>
</br></br></br></br>
And this is the Keyboard, ofcourse yo can right click this :)</br>
<img src="http://i.imgur.com/xkrKz1X.jpg" style="height: 120px; width:120px;">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$('.tlClogo').bind('contextmenu', function(e) {
return false;
});
</script>
</body>
</html>

编辑 2:提供 HTML 文档

关于javascript - 禁用右键单击特定 <div> 或类 ="",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28062979/

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