Javascript DOM onpaste Event via HTML Tag onpaste attribute

Introduction

This example demonstrates how to assign an "onpaste" event to an input element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="text" 
       onpaste="myFunction()" 
       value="Try to paste something in here" size="40">
<p id="demo"></p>
<script>
function myFunction() {//  w w w.  ja va 2  s.com
  document.getElementById("demo").innerHTML = "You pasted text!";
}
</script>
</body>
</html>
Bubbles: Yes
Cancelable: Yes
Event type: ClipboardEvent
Supported HTML tags: All HTML elements



PreviousNext

Related