EventHandler

Provides functionality to add, remove, clear, and trigger events attached to a HTML element.

Methods

add

Adds an event listener to the specified DOM element.

Parameter Type Description
element HTMLElement Document The HTML element to add the event listener to.
eventName String The name of the event.
listener Function Specifies the function to run when the event is called.
bindTo (optional) Object Specifies an object that will bind “this” variable in the event handler.
debounceInterval (optional) Number Specifies the interval to wait until the event is triggered.

Returns: Void

clear

Clears all attached event listeners from the specified DOM element.

Parameter Type Description
element HTMLElement Document The HTML element to clear all event listeners from.

Returns: Void

remove

Removes the specified event listener on the given DOM element.

Parameter Type Description
element HTMLElement Document The HTML element to remove the event listener from.
eventName String The name of the event to remove.
listener Function Specifies the function to remove.

Returns: Void

trigger

Removes the specified event listener on the given DOM element.

Parameter Type Description
element HTMLElement Document The HTML element that the event listener belongs to.
eventName String The name of the event to trigger.
params (optional) Object Specifies additional parameters that will be pass to the event listener.

Returns: Void

On This Page