Skip to content

Block onClick events

Is it possible to block in some time frame (in the example 1s) onClick events after trigger?

0s: onClickEvent
200ms: Block the event
752ms: Block the event
1.2s: OnClickEvent
2.3s: OnClickEvent
2.6s: Block the event

How can I do without timers?


 const loadingTime = + 1000;

 someEl.onclick = event => {
  if( < loadingTime) event.stopPropagation();

Just prevent the event from propagating to other handlers.