Function addEventListener
addEventListener< Target extends keyof HTMLElementEventMap, Listener extends (event: DocumentEventMap[Target]) => void,>( element: Element | Window | Document, target: Target, listener: Listener, options?: boolean | AddEventListenerOptions,): () => void Type Parameters
- Target extends keyof HTMLElementEventMap
- Listener extends (event: DocumentEventMap[Target]) => void
Parameters
- element: Element | Window | Document
- target: Target
- listener: Listener
Optionaloptions: boolean | AddEventListenerOptions
Returns () => void
A utility function to add an event listener to a specified element.
This function adds an event listener for the specified event type and returns a function that can be called to remove the event listener.