Posted By

jmiller on 02/27/11


Tagged

javascript jquery delay keyup


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ReedD19


Keyup callback delay


 / Published in: jQuery
 

URL: http://stackoverflow.com/questions/1909441/jquery-keyup-delay

For something more sophisticated, give a look to the jQuery Typewatch plugin.

  1. // Create Delay Function
  2. var delay = (function() {
  3. var timer = 0;
  4. return function(callback, ms) {
  5. clearTimeout(timer);
  6. timer = setTimeout(callback, ms);
  7. };
  8. })();
  9.  
  10. // Usage:
  11. $('input').on('keyup', function() {
  12. delay(function() {
  13. alert('Time elapsed!');
  14. }, 1000);
  15. });

Report this snippet  

You need to login to post a comment.