English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
document.removeEventListener()Remove the attacheddocument.addEventListener()event handler in the method.
Note:To remove an event handler, the function specified by the addEventListener() method must be an external 'named' function, as shown in the following example (myFunc).
Anonymous function, for example "document.removeEventListener("event"function() { statement );" doesn't work.
UseElement .addEventListener()This method attaches event handlers to the specified element.
UseElement .removeEventListener()This method removes event handlers from the specified element.
document.removeEventListener(event, listener, useCapture)
// Attach event handlers to the document document.addEventListener("mousemove", myFunc); // Remove event handlers from the document document.removeEventListener("mousemove", myFunc);Test to see‹/›
The numbers in the table specify the first browser version that fully supports the removeEventListener() method:
Method | |||||
removeEventListener() | 1 | 1 | 7 | 1.0 | 9 |
Parameter | Description |
---|---|
event | (Required) The name of the JavaScript event to be removed. Do not use the 'on' prefix when using an event, for example, use 'click' instead of 'onclick' or 'mousedown' instead of 'onmousedown'. Please refer to our complete list of all HTML DOM events.HTML DOM Event Object Reference. |
listener | (Required) The name of the JavaScript function to be removed. |
useCapture | (Optional) Boolean value, specifying whether the event is removed in the capture phase or the bubble phase. The default is false. Possible Values:
Note:If the event handler is attached twice, once in the capture phase and once in the bubble phase, it must be removed separately. You can find more information on ourin the JavaScript Event Propagation tutorialRead aboutEvent PropagationFor more information |
Return Value: | None |
---|---|
DOM Version: | DOM 2Level |
JavaScript Tutorial:Event Listener
JavaScript Tutorial:Event Propagation
HTML DOM Reference:document.addEventListener()
HTML DOM Reference:element.removeEventListener()