Javascript DOM HTML Paragraph handle cut Event

Introduction

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<p contenteditable="true" oncut="myFunction()">Try to cut this text</p>

<p id="demo"></p>
<script>
function myFunction() {/*from w w w .  j a  va2  s.c  o m*/
  document.getElementById("demo").innerHTML = "You cut text!";
}
</script>

</body>
</html>



PreviousNext

Related