HTML oncut 事件属性
当用户在 HTML 文档中剪切 HTML 元素的内容时,将触发 oncut 事件属性。
语法
以下是语法 −
<tagname oncut=”script”></tagname>
示例
让我们看一个 HTML oncut 事件属性的示例 −
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
color: #000;
height: 100vh;
background-color: #FBAB7E;
background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
text-align: center;
padding: 20px;
}
p {
font-size: 1.1rem;
}
</style>
</head>
<body>
<h1>HTML oncut Event Attribute Demo</h1>
<p oncut="get()">I'm a paragraph HTML element with some dummy text.</p>
<p style="color:#db133a;">Now try to cut above paragraph text.</p>
<div class="show"></div>
<script>
function get() {
document.body.style.background = "lightblue";
}
</script>
</body>
</html>输出

现在尝试剪切段落元素的内容,以观察 oncut 事件属性如何工作。

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP