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
Execute a JavaScript when pasting some text in an <input> element
The onpaste event occurs when the user pastes some content in an element.
Event | |||||
---|---|---|---|---|---|
onpaste | Yes | Yes | Yes | Yes | Yes |
In HTML:
<element onpaste="myScript">
In JavaScript:
object.onpaste = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("paste", myScript);
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | ClipboardEvent |
Supported HTML tags: | All HTML elements |
Execute a JavaScript when pasting some text in a <p> element (Note that contenteditable is set to "true"):
<p contenteditable="true" onpaste="myFunction()">Try to paste something inside this paragraph.</p>
HTML DOM reference: oncopy event
HTML DOM reference: oncut event