HTML - attributes - oncut

revision:


Content

"oncut" attribute : when the concent of an element is cut. syntax some examples


"oncut" attribute : when the concent of an element is cut.

top

The attribute fires when the user cuts the content of an element.
The oncut attribute is part of the event attributes and can be used on any HTML element. 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 the "contenteditable attribute" to "true".

There are three ways to cut the content of an element:1/ press CTRL + X; 2/ select "Cut" from the edit menu in your browser; 3/ right click to display the context menu and select the "Cut" command.


syntax

top

<element oncut="script">

script: the script to be run on oncut.


some examples

top

codes:
                    <input style="margin-left:3vw;" type="text" oncut="cutIt()" value="Try to cut this text">
                    <p class="spec" id="demo"></p>
                    <script>
                        function cutIt() {
                        document.getElementById("demo").innerHTML = "You cut text!";
                        }
                    </script>
                

Try to cut this text

codes:
                    <p class="spec" contenteditable="true" oncut="cutText()">Try to cut this text</p>       
                    <script>
                        function cutText() {
                        alert("You cut text!");
                        }
                    </script>