Skip to content

removeListener

Mike Byrne edited this page Mar 14, 2023 · 1 revision

description

Introduced 3.1.0

Remove event listeners to node lists instead of singular nodes. (applies removeEventListener to a NodeList)

requires

  • nothing

parameters

  • nodes - required - DOM NodeList to remove event listeners from
  • type - required - event type being listened to
  • func - required - the function to attach
  • options - optional - event listener options

returns

  • nothing

example usage:

function handler() {};

listeners.remove(document.querySelectorAll('button'), 'click', handler);

With options set:

function handler() {};

listeners.remove(document.querySelectorAll('button'), 'click', handler, { passive: true, once: true });

Note Remember, if you want to remove event listeners, you need to specify the same function reference and same options when removing as when adding.