/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: onpaste

[this page | pdf | back links]

The HTML onpaste attribute specifies the event that is triggered when the user pastes content in an element. It applies to all visible elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
onpaste: try copying some text and
then pasting it into this input box:
<input type="text" value="Hello" id="pasteinput" onpaste="myOnpaste()"><br> 

<script>
function myOnpaste() {
  document.getElementById("pasteinput").style.background = "orange";
}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile