Horje
HTML oncut Event Attribute
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 of HTML oncut Event Attribute

It will Execute a JavaScript when cutting some text in an <input> element.
index.html
Example: HTML
 <input type="text" oncut="myFunction()" value="Try to cut this text"> 

Output should be:

Example of HTML oncut Event Attribute

Definition and Usage of HTML oncut Event Attribute

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:

Browser Support of HTML oncut Event Attribute

Browser Support of HTML oncut Event Attribute

Syntax of HTML oncut Event Attribute

<element oncut="script">

Attribute Values of HTML oncut Event Attribute

Value Description
script The script to be run on oncut

Technical Details of HTML oncut Event Attribute

Supported HTML tags: ALL HTML elements

How to execute a JavaScript when cutting some text in an <input> element

The code is to Try to cut this text.

index.html
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>

Output should be:

How to execute a JavaScript when cutting some text in an <input> element

How to execute a JavaScript when cutting some text of a <p> element (Note that contenteditable is set to "true")

The code is to try to cut this tex.

index.html
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>

Output should be:

How to execute a JavaScript when cutting some text of a <p> element (Note that contenteditable is set to "true")




html event attributes

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Clipboard Events Attribute
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference