Menu

gitpiper

off javascript Code Snippet in 2024

browsereventintermediate

Last Updated: 6 April 2024

Removes an event listener from an element.

  • Use EventTarget.removeEventListener() to remove an event listener from an element.
  • Omit the fourth argument opts to use false or specify it based on the options used when the event listener was added.
const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts);
const fn = () => console.log('!'); document.body.addEventListener('click', fn); off(document.body, 'click', fn); // no longer logs '!' upon clicking on the page

javascript snippet similar to off For You in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️