Posted By

Jman on 08/12/11


Tagged

delay keyup


Versions (?)

Delay


 / Published in: JavaScript
 

for example add delay before keyup callback fired

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

Report this snippet  

You need to login to post a comment.