Execute a JavaScript when copying some text of a <p> element: - Javascript DOM Event

Javascript examples for DOM Event:oncopy

Description

Execute a JavaScript when copying some text of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p oncopy="myFunction()">Try to copy this text</p>

<script>
function myFunction() {//from  ww w.  j  a  v a 2s. c o  m
    console.log("You copied text!");
}
</script>

</body>
</html>

Related Tutorials