目录

oncut Event

Example

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


Description

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 Occurs When
copy The user copies content
cut The user starts cuts content
paste The user pastes content

See Also:

The Cliboard Event Object


Syntax

In HTML:

< element oncut=" myScript">
Try it Yourself »

In JavaScript:

object.oncut = function(){ myScript};
Try it Yourself »

In JavaScript, using the addEventListener() method:

object.addEventListener("cut", myScript);
Try it Yourself »


Technical Details

Bubbles: Yes
Cancelable: Yes
Event type: ClipboardEvent
HTML tags: All HTML elements

More Examples

Example

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 »

Browser Support

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