admin管理员组文章数量:1355520
Here, I'm having a problem with copy option when select 3 elements all the three are getting copied. But, I have a Jquery function to disable copy for the middle element. How I can disable that while selecting 3 elements. But, If I select the middle element individually it's not copying.
$('#notcp').bind('cut copy paste', function (e) {
e.preventDefault();
});
<script src=".1.1/jquery.min.js"></script>
<p >
select and copy
</p>
<p id="notcp">
cannot copy
</p>
<p>
select and copy
</p>
Here, I'm having a problem with copy option when select 3 elements all the three are getting copied. But, I have a Jquery function to disable copy for the middle element. How I can disable that while selecting 3 elements. But, If I select the middle element individually it's not copying.
$('#notcp').bind('cut copy paste', function (e) {
e.preventDefault();
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p >
select and copy
</p>
<p id="notcp">
cannot copy
</p>
<p>
select and copy
</p>
Share
Improve this question
asked May 26, 2017 at 11:53
Satya PendemSatya Pendem
3255 silver badges14 bronze badges
4 Answers
Reset to default 3Use This CSS Style to disable Selection. By this The Text will not be selected. Thus can't be copied also.
#notcp {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
This feature can be done via disabling Text Selection using few CSS lines:
html, body {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
try add return false;
$('#notcp').bind('copy paste',function(e) {
e.preventDefault(); return false;
});
Try with this.
$(document).on("cut copy paste","#notcp",function(e) {
e.preventDefault();
});
本文标签: javascripthow to disable copy for particular element in htmlStack Overflow
版权声明:本文标题:javascript - how to disable copy for particular element in html - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743992932a2572479.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论