如何使用 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>

更新時間:14-Feb-2020

已閱讀 2K+ 次

開啟你的 職業生涯

完成該課程即可獲得認證

開始學習
廣告
© . All rights reserved.