|
|
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. |
<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.
<!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.
<!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 |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Clipboard Events Attribute |
Uploaded by: | Admin |
Read Articlehttps://develop.horje.com/learn/1434/reference