HTMLElement.onClickEvent method
HTMLElement › onClickEvent
Official
Adds a click event listener to the element.Signature:
onClickEvent(this: HTMLElement, listener: (this: HTMLElement, ev: MouseEvent) => unknown, options?: boolean | AddEventListenerOptions | undefined): voidParameters:
| Parameter | Type | Description |
|---|---|---|
| this | HTMLElement | The element to add the event listener to. |
| listener | (this: HTMLElement, ev: MouseEvent) => unknown | The listener to call when the click event is triggered. |
| options? | boolean | AddEventListenerOptions | undefined | The options of the click event listener. |
Returns: void
Example:
document.body.onClickEvent((ev) => { console.log(ev);});