Javascript DOM oncut Event via addEventListener() method

Introduction

In JavaScript, using the addEventListener() method:

object.addEventListener("cut",
       myScript);

This example uses the addEventListener() method to attach a "cut" event to an input element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="text" id="myInput" value="Try to cut this text">

<p id="demo"></p>
<script>
document.getElementById("myInput").addEventListener("cut", myFunction);

function myFunction() {/* w w  w. j  a  v a  2s. c om*/
  document.getElementById("demo").innerHTML = "You cut text!";
}
</script>

</body>
</html>
Bubbles: Yes
Cancelable: Yes
Event type: ClipboardEvent
Supported HTML tags: All HTML elements



PreviousNext

Related