Execute a JavaScript when pasting some text in a <p> element (Note that contenteditable is set to "true"): - Javascript DOM Event

Javascript examples for DOM Event:onpaste

Description

Execute a JavaScript when pasting some text in a <p> element (Note that contenteditable is set to "true"):

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p contenteditable="true" onpaste="myFunction()">Try to paste something inside this paragraph.</p>

<script>
function myFunction() {/*from w w  w  .j av a  2  s . co m*/
    console.log("You pasted text!");
}
</script>

</body>
</html>

Related Tutorials