removeEventListener method

void removeEventListener(
  1. String type,
  2. EventListener? callback, [
  3. JSAny options
])

The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

Calling removeEventListener() with arguments that do not identify any currently registered event listener on the EventTarget has no effect.

If an event listener is removed from an EventTarget while another listener of the target is processing an event, it will not be triggered by the event. However, it can be reattached.

Warning: If a listener is registered twice, one with the capture flag set and one without, you must remove each one separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.

Event listeners can also be removed by passing an AbortSignal to an EventTarget/addEventListener and then later calling AbortController/abort on the controller owning the signal.

Implementation

external void removeEventListener(
  String type,
  EventListener? callback, [
  JSAny options,
]);