Skip to content

Document.off method

Document › off

Official

Removes an event listener from the document.

Signature:

off(this: Document, type: K, selector: string, listener: (this: Document, ev: DocumentEventMap[K], delegateTarget: HTMLElement) => unknown, options?: boolean | AddEventListenerOptions | undefined): void

Parameters:

Parameter Type Description
this Document The document to remove the event listener from.
type K The type of event to listen for.
selector string The selector of the event target.
listener (this: Document, ev: DocumentEventMap[K], delegateTarget: HTMLElement) => unknown The listener to call when the event is triggered.
options? boolean | AddEventListenerOptions | undefined The options of the event listener.

Returns: void

Example:

document.off('click', 'div', document.body._EVENTS.click[0].listener);