addEventListener("copy", myFunction); - Javascript DOM Event

Javascript examples for DOM Event:addEventListener

Description

The oncopy event occurs when copying the content of an element.

Summary

Bubbles Yes
Cancelable Yes
Supported HTML tags: All HTML elements

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="text" id="myInput" value="Try to copy this text">

<script>
document.getElementById("myInput").addEventListener("copy", myFunction);

function myFunction() {/*www  .  j av a 2s . c  o m*/
    console.log("You copied text!");
}
</script>

</body>
</html>

Related Tutorials