Skip to content

Function: removeEvent() ​

ts
function removeEvent(
   el, 
   type, 
   callback?, 
   options?): void;

Remove an event listener from an element.

Parameters ​

ParameterTypeDescription
elElementThe element to remove the event listener from.
typestringThe event type to remove.
callbackEventListenerThe callback function to remove.
optionsRemoveEventOptionsThe options object.

Returns ​

void

Example ​

ts
const el = document.getElementById('my-element');
const callback = () => {
  console.log('Button clicked');
};

// Add the event listener
addEvent(el, 'click', callback, { useCapture: false });

// Remove the event listener
removeEvent(el, 'click', callback, { useCapture: false });

Since ​

1.0.0

Released under the MIT License.