Skip to content
Related Articles

Related Articles

Improve Article

HTML | onpaste Event Attribute

  • Difficulty Level : Basic
  • Last Updated : 03 Dec, 2018

The onpaste attribute works when some content are paste in an element. This event attribute is supported by all HTML elements. It is mostly used with <input> element.

There are three ways to paste the content in an HTML elements which are listed below:

  • Use CTRL + V key
  • Select “Paste” from the edit menu in browser.
  • select the “Paste” command from right click menu


<element onpaste = "script">

Attribute Value: The script event run when onpaste attribute is called.


<!DOCTYPE html>
        <title>onpaste attribute</title>
            body {
            h1 {
        <h2>onpaste Attribute</h2>
        <input type="text" onpaste="Geeks()" 
        value="A computer science portal for geeks" size="40">
        <p id="sudo"></p>
            function Geeks() {
                document.getElementById("sudo").innerHTML = "pasted text!";


Supported Browsers: The browser supported by onpaste attribute are listed below:

  • Apple Safari
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :