Last Updated : 11 Jul, 2025
This attribute fires when the user cut or deletes the content that has been present in the element. It is a Boolean-type attribute. This attribute is supported by all HTML elements but it is possible for that element which has a ContentEditable attribute set to "true".
Note:There are 3 ways to cut the content of an element:
Syntax:
<element oncut = "script">
Attribute: This attribute is part of the event attribute and it can be used in any HTML element. The script will be run when oncut attribute call.
Example 1: In this example we use the oncut attribute to trigger a JavaScript function when text is cut from the input field, displaying "Cut the text!" in a paragraph below the input.
HTML
<!DOCTYPE html>
<html>
<head>
<title>oncut attribute</title>
<style>
body {
text-align: center;
}
h1 {
color: green;
}
</style>
</head>
<body>
<h1>GeeksForGeeks</h1>
<h2>oncut attribute in input element</h2>
<input type="text"
oncut="Geeks()"
value="GeeksForGeek: A computer science portal for Geeks">
<p id="sudo"></p>
<script>
function Geeks() {
document.getElementById("sudo").innerHTML = "Cut the text!";
}
</script>
</body>
</html>
Output:
Example 2: In this example we use the oncut attribute on a contenteditable paragraph. When text is cut, an alert saying "Cut the text!" appears.
HTML
<!DOCTYPE html>
<html>
<head>
<title>oncut attribute</title>
<style>
body {
text-align: center;
}
h1 {
color: green;
}
</style>
</head>
<body>
<h1>GeeksForGeeks</h1>
<h2>oncut attribute in input element</h2>
<p contenteditable="true"
oncut="Geeks()">
GeeksforGeeks: A computer science portal for geeks.
</p>
<script>
function Geeks() {
alert("Cut the text!");
}
</script>
</body>
</html>
Output:
Supported Browsers: The browser supported by oncut attribute are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4