Skip to content

Instantly share code, notes, and snippets.

@pauca
Created January 18, 2017 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pauca/fb6f80eb5781da971cb893614be635b2 to your computer and use it in GitHub Desktop.
Save pauca/fb6f80eb5781da971cb893614be635b2 to your computer and use it in GitHub Desktop.
Example of jQuery of Paste on textarea and do an action
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Paste&Go</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" ></script>
<script>
$( document ).ready(function() {
console.log( "ready!" );
$("#input1").bind('paste',null, function(e) {
var elem = $(this);
setTimeout(function() {
// gets the copied text after a specified time (100 milliseconds)
e.preventDefault();
var ks = $('#input1').val()
$("#div1").empty();
$("#div1").append(ks);
});
}, 100);
});
</script>
<style>
</style>
</head>
<body>
<h4>Paste Text Below</h4>
<textarea id="input1" rows="4" cols="50" maxlength="5000"></textarea>
</br></br></br>
<div id="div1"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment