当用户剪切元素的文本时,oncut属性将在HTML中触发。
您可以尝试运行以下代码来实现oncut属性-
<!DOCTYPE html> <html> <body> <input type = "text" oncut = "display()" value = "Cut me"> <h2 id = "test">Try to cut the above text.</h2> <script> function display() { document.getElementById("test").innerHTML = "您的剪切文字有效!"; } </script> </body> </html>