HTML event attribute onpaste








The onpaste attribute event is triggered when pasting some content.

What's new in HTML5

None.

Syntax

<element onpaste="script or Javascript function name">

Supported Tags

ALL HTML elements

Browser compatibility

onpaste Yes Yes Yes Yes Yes




Example

<!DOCTYPE html>
<html>
<body>
<!--  w  w  w  .j ava 2 s . c  om-->
<p onpaste="myFunction()">Cut me by pressing ctrl-x</p>

<script>
function myFunction() {
    console.log("onpaste!");
}
</script>

</body>
</html>

Click to view the demo