Created
May 26, 2017 12:17
-
-
Save maneja81/6b37f634f184976471c2a95caf558303 to your computer and use it in GitHub Desktop.
jQuery run function after user finished typing
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
let typingTimer; //timer identifier | |
let doneTypingInterval = 1500; //time in ms, 5 second for example | |
let $input = $('.search-sidebar-ui-blocks'); | |
//on keyup, start the countdown | |
$input.on('keyup', function () { | |
clearTimeout(typingTimer); | |
typingTimer = setTimeout(doneTyping, doneTypingInterval); | |
}); | |
//on keydown, clear the countdown | |
$input.on('keydown', function () { | |
clearTimeout(typingTimer); | |
}); | |
//user is "finished typing," do something | |
function doneTyping() { | |
// do something here.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment