HTML DOM Element removeEventListener() Method

Definition and usage

removeEventListener() Method to remove event handlers from an element.

See also:

Element methods:

addEventListener() method

removeEventListener() method

Document methods:

addEventListener() method

removeEventListener() method

Tutorial:

HTML DOM EventListener

Complete list of DOM events

Example

Remove the "mousemove" event from the element:

myDIV.removeEventListener("mousemove", myFunction);

Try it yourself

Syntax

element.removeEventListener(type, listnener, useCapture)

Parameters

Parameters Description
type

Required. The event type of the event listener to be removed.

Do not use the "on" prefix. For example, use "click" instead of "onclick".

For a complete list of HTML DOM events, please visit:HTML DOM Event Object Reference Manual.

listnener Required. The event listener function to be removed.
useCapture

Optional (default is false).

  • true - Remove the handler from the capture
  • false - Remove the handler from the bubble

If the event handler is appended twice, once for capture and once for bubble, each must be removed separately.

Return value

None.

Technical details

removeEventListener() This method will remove the specified event listener function. Parameters type and useCapture must be called with addEventListener() The corresponding parameters of the method are the same. If no event listener that matches the specified parameters is found, this method does nothing.

If an event listener function is removed by this method, it will no longer be called when the specified type of event occurs on the node. Even if an event listener is removed by another event listener of the same type registered on the same node, it will not be called again.

This method is also Document and Window Object definition, and the working method is similar.

Browser support

element.removeEventListener() It is a DOM Level 2 (2001) feature.

All browsers fully support it:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support 9-11 Support Support Support Support