Created
May 17, 2014 15:43
-
-
Save drakakisgeo/5f1e3eac8d0fc6dedfb0 to your computer and use it in GitHub Desktop.
Delay keyup in Jquery
This file contains hidden or 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
| *** executing a function after the user has stopped typing for a specified amount of time *** | |
| *** From http://stackoverflow.com/questions/1909441/jquery-keyup-delay *** | |
| var delay = (function(){ | |
| var timer = 0; | |
| return function(callback, ms){ | |
| clearTimeout (timer); | |
| timer = setTimeout(callback, ms); | |
| }; | |
| })(); | |
| Usage: | |
| $('input').keyup(function() { | |
| delay(function(){ | |
| alert('Time elapsed!'); | |
| }, 1000 ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment