how a can get this, in jQuery: call some function with working code after delay(3s), IF i call function again before delay from first call in not done, then reset delay and call new 3s.
Example:
fce MeDeday(3s) – after time down – alert(“hello”);
situation 1:
call MeDelay() – time down – alert(“hello”)
situation 2:
call MeDelay()
still remain 2s from first call
reset time and again wait 3s, no 2s + 5s and fired 2times alert(“hello”)
call MeDelay() – time down – alert(“hello”)
This is called debouncing, which is closely related to throttling. There’s a nice jQuery plugin for that: jQuery throttle/debounce.
I think this is the use case you’re looking for:
Demo →