oncut
Event
Example
Execute JavaScript when the selected content within an <input>
element is cut:
<input type="text" oncut="myFunction()" value="Try cutting this text">
See more examples at the bottom of this page.
Definition and Usage
The oncut event is triggered when the user cuts the content of an element.
Note: Although the oncut event is supported by all HTML elements, it is not actually supported by all elements, such as <p>
elements, unless the contenteditable attribute is set to "true" (see more examples below).
Tip: The oncut event is commonly used with <input>
elements of type="text".
Tip: There are three ways to cut content:
- Press CTRL + X
- Select "Cut" from the browser's edit menu
- Right-click and select "Cut" from the context menu.
Browser Support
Event | |||||
---|---|---|---|---|---|
oncut | Yes | Yes | Yes | Yes | Yes |
Syntax
In HTML:
In JavaScript:
In JavaScript, using the addEventListener() method:
Note: Internet Explorer 8 and earlier versions do not support the addEventListener() method.
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
--- | --- |
Event Type: | ClipboardEvent |
--- | --- |
Supported HTML Tags: | All HTML elements |
--- | --- |
More Examples
Example
Execute JavaScript when text content is cut from a <p>
element (note the contenteditable attribute set to "true"):
<p contenteditable="true" oncut="myFunction()">Try cutting this text</p>
Related Pages
HTML DOM Reference: oncopy Event
HTML DOM Reference: onpaste Event