Skip to main content

off

Removes the event listener in target's event listener list with the same type, callback, and options.

API

function off<T extends EventTarget>(
obj: T | null,
...args:
| Parameters<T["removeEventListener"]>
| [string, EventListenerOrEventListenerObject | CallableFunction, ...any]
): void;

Usage

import { off } from "@feedzai/js-utilities";

function callback(event) {
event.stopPropagation();
}

// Remove event from DOM element
off(document.querySelector("h1"), "click", callback)