HTML | oncut Attribute

This attribute fires when the user cut or delete 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:

  • Press CTRL + X
  • Select “Cut” from the Edit menu in your browser
  • Right click and then select the “Cut” command

Syntax:

<element oncut = "script">

Attribute: This attribute is a part of event attribute and it can be used in any HTML elements. The script will be run when oncut attribute call.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                    

chevron_right


Output:

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                    

chevron_right


Output:

Supported Browsers: The browser supported by oncut attribute are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.