![]() |
Definition and UsageThe Note: Although the Tip: The Tip: There are three ways to paste some content in an element:
Applies toThe
Browser Support |
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<input type="text" onpaste="myFunction()" value="Try to paste something in here" size="40">
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "You pasted text!";
}
</script>
</body>
</html>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p contenteditable="true" onpaste="myFunction()">Try to paste something inside this paragraph.</p>
<script>
function myFunction() {
alert("You pasted text!");
}
</script>
</body>
</html>
html onpaste attribute |
HTML onpaste Attribute | HTML Attribute |
How to Execute a JavaScript when pasting some text in a <p> element (Note that contenteditable is set to "true") - HTML onpaste Attribute | HTML Attribute |
Read Full: | HTML Attribute |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Attribute |
Uploaded by: | Admin |
Views: | 75 |
Reffered: https://www.w3schools.com/tags/att_onpaste.asp