Skip to content

Instantly share code, notes, and snippets.

@virtualmayur
Created November 6, 2013 07:19
Show Gist options
  • Save virtualmayur/7332228 to your computer and use it in GitHub Desktop.
Save virtualmayur/7332228 to your computer and use it in GitHub Desktop.
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>keyup demo</title> <style> fieldset { margin-bottom: 1em; } input { display: block; margin-bottom: .25em; } #print-output { width: 100%; } .print-output-line { white-space: pre; padding: 5px; font-family: monaco, monospace; font-size: .7em; } </style> <script src="http://code.jquery.com/jquery-1.9.1.js"></script></head><body> <form> <fieldset> <label for="target">Type Something:</label> <input id="target" type="text"> </fieldset></form><button id="other"> Trigger the handler</button><script type="text/javascript" src="/resources/events.js"></script> <script>var xTriggered = 0;$( "#target" ).keyup(function( event ) { xTriggered++; var msg = "Handler for .keyup() called " + xTriggered + " time(s)."; $.print( msg, "html" ); $.print( event );}).keydown(function( event ) { if ( event.which == 13 ) { event.preventDefault(); }}); $( "#other").click(function() { $( "#target" ).keyup();});</script> </body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment