Call a function when cutting some text in an <input> element:
<input type="text" oncut="myFunction()" value="Try to cut this text">
Try it Yourself »
More examples below
The oncut
event occurs when the user cuts the content of an element.
The oncut
event is mostly used on <input> elements with type="text".
It is only possible to cut something from an input field.
It is not possible to cut the content of, for example a <p> element, UNLESS the element has set contenteditable to "true" (See "More Examples" below).
Event | Occurs When |
---|---|
copy | The user copies content |
cut | The user starts cuts content |
paste | The user pastes content |
In JavaScript, using the addEventListener() method:
object.addEventListener("cut",
myScript);
Try it Yourself »
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | ClipboardEvent |
HTML tags: | All HTML elements |
Call a function when cutting some text of a <p> element.
(Note that contenteditable is set to "true"):
<p contenteditable="true" oncut="myFunction()">Try to cut this text</p>
Try it Yourself »
oncut
is a DOM Level 3 (2004) feature.
It is fully supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!