![]() |
The
oncut event attribute in HTML specifies a script to be executed when a user cuts the content of an HTML element. This event is part of the Clipboard Events in HTML. |
Example:
HTML
<input type="text" oncut="myFunction()" value="Try to cut this text">
The oncut attribute fires when the user cuts the content of an element.
Note: Although the oncut attribute is supported by all HTML elements, it is not actually possible to cut the content of, for example, a <p> element, UNLESS the element has set contenteditable to "true" (See "More Examples" below).
Tip: The oncut attribute is mostly used on <input> elements with type="text".
Tip: There are three ways to cut the content of an element:
<element oncut="script">
Value | Description |
---|---|
script | The script to be run on oncut |
Supported HTML tags: | ALL HTML elements |
---|
The code is to Try to cut this text.
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<input type="text" oncut="myFunction()" value="Try to cut this text">
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "You cut text!";
}
</script>
</body>
</html>
The code is to try to cut this tex.
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p contenteditable="true" oncut="myFunction()">Try to cut this text</p>
<script>
function myFunction() {
alert("You cut text!");
}
</script>
</body>
</html>
html event attributes |
List of Clipboard Events Attribute | Clipboard Events Attribute |
HTML oncopy Event Attribute | Clipboard Events Attribute |
HTML oncut Event Attribute | Clipboard Events Attribute |
HTML onpaste Event Attribute | Clipboard Events Attribute |
Example of HTML oncut Event Attribute | Clipboard Events Attribute |
Definition and Usage of HTML oncut Event Attribute | Clipboard Events Attribute |
Browser Support of HTML oncut Event Attribute | Clipboard Events Attribute |
Syntax of HTML oncut Event Attribute | Clipboard Events Attribute |
Attribute Values of HTML oncut Event Attribute | Clipboard Events Attribute |
Technical Details of HTML oncut Event Attribute | Clipboard Events Attribute |
How to execute a JavaScript when cutting some text in an <input> element | Clipboard Events Attribute |
How to execute a JavaScript when cutting some text of a <p> element (Note that contenteditable is set to "true") | Clipboard Events Attribute |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | Clipboard Events Attribute |
Uploaded by: | Admin |
Reffered: https://www.w3schools.com/tags/ev_oncut.asp