HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The oncopy attribute fires when the user copies the content of an element."
The oncopy
attribute fires when the user copies the content of an element.
oncopy
attribute also fires when the user copies an
element, for example, an image, created with the <img>
element.
oncopy
attribute is mostly used on
<input>
elements
with type="text"
.
The oncopy
attribute is part of the Event Attributes, and can be used on any HTML elements.
Elements | Event |
---|---|
All HTML elements | oncopy |
Execute a JavaScript when copying some text of an <input> element:
<input type="text" oncopy="myFunction()" value="Try to copy this text">
Execute a JavaScript when copying some text of a <p> element:
<p oncopy="myFunction()">Try to copy this text</p>
Execute a JavaScript when copying an image:
<img src="w3resource.gif" oncopy="myFunction()">
Event Attribute | |||||
---|---|---|---|---|---|
oncopy | Yes | Yes | Yes | Yes | Yes |