Horje

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

P Example.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

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

<script>
function myFunction() {
  alert("You copied text!");
}
</script>

</body>
</html>

Output should be:

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




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin