Created
August 19, 2013 02:41
-
-
Save callblueday/6265378 to your computer and use it in GitHub Desktop.
当用户在输入框中输入停顿一段时间后,会执行函数
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
$(".location").bind("input", function() { | |
var $this = $(this); | |
var delay =250; // delay after last input | |
clearTimeout($this.data('timer')); | |
$this.data('timer', setTimeout(function(){ | |
$this.removeData('timer'); | |
doSomething(); | |
}, delay)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment