oncut Event
Example
Execute a JavaScript 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
Definition and Usage
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".
Note
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).
3 Ways to Cut:
- Press Ctrl + X
- Select "Cut" from the Edit menu in your browser
- Right click to display the context menu, and select "Cut"
Clipboard Events
Event | Description | Bubbles |
---|---|---|
copy | The user copies content | Yes |
cut | The user starts cuts content | Yes |
paste | The user pastes content | Yes |
See Also:
Syntax
In JavaScript, using the addEventListener() method:
object.addEventListener("cut", myScript);
Try it Yourself »
Technical Details
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | ClipboardEvent |
Supported HTML tags: | All HTML elements |
More Examples
Example
Execute a JavaScript 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 »
Browser Support
oncut
is a DOM Level 3 (2004) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |