Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (16 sloc) 1.26 KB

removeEventListener can be called on an eventTarget if the event handler was added with [[addEventListener|Add Event Listener]] using a [[named function]] as opposed to a [[anonymous function]].


var namedCallbackFunction = function( eventObj ){
    // write code to respond to event in here
    // log eventObj to see the cool stuff on the event object

  .addEventListener('eventType', namedCallbackFunction, false);

  .removeEventListener('eventType', namedCallbackFunction, false);


eventTarget.addEventListener('eventTarget', namedCallbackFunction, useCapture)
  • ** eventTarget**: an object against which an event may be dispatched (eg: the window, document, an element, etc.)
  • type: A string indicating the [[event|Events]] type to unbind from.
  • namedCallbackFunction: The named function to be unbound from the eventTarget.
  • useCapture: (optional) If true, useCapture specifies whether the EventListener being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.
Something went wrong with that request. Please try again.