DOM EventTarget.removeEventListener() Method
The removeEventListener() method removes an event listener that was added with addEventListener(), using the same event type and function.
Description
The removeEventListener() method removes a listener previously registered with addEventListener(). You must pass the same function reference and the same capture setting; an identical-looking anonymous function is a different function and won't remove anything.
Alternatives are the once: true option for listeners that should run a single time, and the signal option with an AbortController, which can remove many listeners at once.
Listeners that are already scheduled to run in the current dispatch still run if they're removed by an earlier listener for the same event. Removing listeners is important for components that are added and removed from the page repeatedly, since forgotten listeners on long-lived objects such as window keep the component's data in memory.
Syntax
target.removeEventListener(type, listener)
target.removeEventListener(type, listener, options)Parameters
- typeThe event type, such as
"click". - listenerThe same function that was passed to
addEventListener(). - optionsOptional. Must have the same
capturesetting used when adding.
Return Value
None (undefined).
Example
Browser Support
The following information will show you the current browser support for the EventTarget.removeEventListener() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





