cancel an event in javascript

Solutions on MaxInterview for cancel an event in javascript by the best coders in the world

showing results for - "cancel an event in javascript"
Eléonore
01 Jan 2021
1// call the preventDefault() method on the event
2function preventScrollWheel(event) {
3  if (typeof event.cancelable !== 'boolean' || event.cancelable) {
4    event.preventDefault();
5  } else {
6    // to call preventDefault() on it.
7    console.warn(`The following event couldn't be canceled:`);
8    console.dir(event);
9  }
10}
11
12document.addEventListener('wheel', preventScrollWheel);