Created
January 18, 2017 10:19
-
-
Save pauca/fb6f80eb5781da971cb893614be635b2 to your computer and use it in GitHub Desktop.
Example of jQuery of Paste on textarea and do an action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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