Is it possible to do this: suppose that there are a lot of same events fire a lot of times in a period of time, we will cancel all the previous event and only use the last one.
The last event will be for for one time only when there is no more event for 3 seconds.
For example: there is a button; we will let user click this button many times as they want and we will not disable this button. No matter how many times user have been clicking this we will consider it to be only one click count as the last click. The click event will be performed when there are no more clicks within 3 seconds.
What you are looking for is known as debouncing. For this task there is already a superb plugin/library from Ben Alman.
fiddle