.onClick
<HTMLElement>
.onClick()
Attaches an event handler callback function to the “click” event of an element.
Usage:
HTMLElement
=
Element
.
onClick
(
callback
)
Member of:
HTMLElement
Parameters:
callback
– the function to call when the “click” event occurs (required).
Returns:
The
HTMLElement
it was called on, thus allowing for command chaining.
Notes:
This is just a shorthand function for the
.on
method, specific for the “click” event. See there for more information and examples.
The “click” event handler can be attached to any
HTMLElement
, but of course only makes sense for elements which are can actually be clicked.
See also
.on
.off
More information
EventTarget: addEventListener() method
on
MDN
.