Web APIs
EventTarget.removeEventListener()
Removes a matching listener using type, callback identity and capture flag. Other options do not participate in removal matching.
Formal Syntax & Structure
javascript syntaxjavascript
target.removeEventListener(type, callback, options?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| type | string | Event name. |
| callback | function | EventListener object | null | Same listener identity. |
| options | boolean | object | Capture flag or options. |
Return Value
undefined
No return value.
Working Example
Example Snippetjavascript
const b=document.createElement("button");let n=0;const hit=()=>n++;b.addEventListener("click",hit);b.click();b.removeEventListener("click",hit);b.click();console.log(n);