revision:
The onpaste attribute fires when the user pastes some content in an element.
The onpaste attribute is part of the event attributes and can be used on any HTML element. It is mostly used on <input> elements with type="text".
There are three ways to paste some content in an element:1/ press CTRL + V; 2/ select "Paste" from the Edit menu in your browser; 3/ right click to display the context menu and select the "Paste" command
<element onpaste="script"></element>
script: the script event runs when the onpaste attribute is called.
<input style="margin-left:3vw;" type="text" onpaste="textPaste()" value="Try to paste something in here" size="40"> <p class="spec" id="demo"></p> <script> function textPaste() { document.getElementById("demo").innerHTML = "You pasted text!"; } </script>
I'm a paragraph element with some dummy text. I'm a paragraph element with some dummy text. I'm a paragraph element with some dummy text. I'm a paragraph element with some dummy text. I'm a paragraph element with some dummy text.
<textarea style="margin-left:3vw;" placeholder="Paste above text here" onpaste="pasteFn()" rows='8' cols="50" required></textarea> <script> function pasteFn() { document.querySelector('textarea').style.background = 'lightgreen'; } </script>