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