oncutEvent

事件对象参考手册Event Object

Examples

Execute JavaScript when the selected content in an <input> element is cut:

<input type="text" oncut="myFunction()" value="Try to cut this text">

Try it Yourself »

See more examples at the bottom of this article.


Definition and Usage

The oncut event triggers when the user cuts the content of an element.

Note:Although all HTML elements support the oncut event, in reality not all elements support it, for example <p> elements, unless contenteditable is set to "true" (see more examples below).

Tip:The oncut event is typically applied to <input> elements with type="text".

Tip:There are three ways to cut content:

  • Press CTRL + X
  • Select "Cut" from the browser's edit menu
  • Right-click the mouse button and select the "Cut" command from the context menu.

Browser Support

Event
oncut Yes Yes Yes Yes Yes


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

Note:Internet Explorer 8 and earlier IE versions do not supportaddEventListener()method.


Technical Details
Bubbles: Yes
Cancelable: Yes
Event type: ClipboardEvent
Supported HTML tags: All HTML elements


Examples

More Examples

Example

Execute JavaScript when cutting text content on a <p> element (note that contenteditable is set to "true"):

<p contenteditable="true" oncut="myFunction()">Try to cut this text</p>

Try it Yourself »


Related Pages

HTML DOM Reference:oncopy Event

HTML DOM Reference:onpaste Event


事件对象参考手册Event Object Other Extensions