Skip to content

Instantly share code, notes, and snippets.

@callblueday
Created August 19, 2013 02:41
Show Gist options
  • Save callblueday/6265378 to your computer and use it in GitHub Desktop.
Save callblueday/6265378 to your computer and use it in GitHub Desktop.
当用户在输入框中输入停顿一段时间后,会执行函数
$(".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