I am trying to identify if the window loses focus after 3 seconds of submit.
Currently I have this:
$("input").on("submit",function(){
$(window).blur(function(){
console.log(a);
})
});
But this, no matter when you press submit, if you click outside the window or minimize the window the console.log
triggers a
.
This is what I am trying to achieve:
- User submits form
- In a period of 3 seconds, if the window loses focus do console.log(a);
- After 3 seconds, if the window loses focus do nothing.
- If the user submits again on the same session, repeat from step 1.