如何使用 jQuery 停用複製內容功能?
要停用 jQuery 中內容的剪下、複製和貼上,請使用 jQuery bind() 函式。
示例
你可以執行以下程式碼嘗試使用 jQuery 停用內容的複製貼上 −
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#mytext').bind("cut copy paste",function(e) {
e.preventDefault();
});
});
</script>
</head>
<body>
<input type = "text" id="mytext">Copy, cut and paste function doesn't work here.
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP