Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

oncut — handling the cut event

The oncut attribute contains JavaScript that handles the cut event. It can appear on any HTML element; in the example, it updates a status message and cancels the default cut action.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

oncut="JavaScript statements"

oncut is a global HTML attribute that handles the cut event. Its value is JavaScript code, not an event name or a script URL. Being global means that the attribute can appear on any HTML element, not only editable fields.

Inside the attribute code, the event parameter provides the event. Returning false cancels its default action if the event is cancelable. Merely running the handler does not imply cancellation.

The example uses a textarea. Select Alpha and invoke the cut command. The expected message is cut handled, and the field retains Alpha Beta because the code executes return false;. The example requires an environment that permits inline event handlers.

Examples

<!doctype html>
<meta charset="utf-8">
<title>oncut demo</title>
<textarea oncut="document.getElementById('status').textContent = 'cut handled'; return false;">Alpha Beta</textarea>
<p id="status">waiting</p>

Result

cut handled

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources