Web APIs

EventTarget.removeEventListener()

Try the free JavaScript compiler

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

NameTypeDescription
typestringEvent name.
callbackfunction | EventListener object | nullSame listener identity.
optionsboolean | objectCapture 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);
JavaScript Reference