/

HTML / CSS / JavaScript Tutorial

JavaScript DOM HTML method: removeEventListener()

[this page | pdf | back links]

The removeEventListener() method (when applied to HTML elements in the JavaScript DOM) removes (detaches) an event handler from the element.

 

It has the following syntax with the following parameters. It does not return any value.

 

element.removeEventListener(event, function, useCapture)

 

Parameter

Required / Optional

Description

event

Required

String specifying event (excluding the ‘on’ part at the start of the relevant event attribute name)

function

Required

Name of function (with ‘()’ included at end)

useCapture

Optional

If true then event handler is executed in the capturing phase of the page load, if false then in the bubbling phase

 

Some earlier versions of some major browsers do not support this method. For these browsers you instead need to use the detachEvent() method. If the event listener was attached two times, once in the capturing and ones in the bubbling phase using the useCapture parameter then it needs to be removed twice as well.

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile