Adds an event handler that runs when the element is clicked.
An element receives a
click event when a user clicks on the element
When a user double-clicks an element, two
click events are fired
doubleClick event is also fired.
Note: Do not use the Editor Link panel to redirect on click when a link is already defined using the
onClick()function. To avoid unpredictable behavior, remove the link from the Editor Link panel.
Deprecation note: The $w parameter of event handlers is being deprecated. To get a scoped selector for working with elements in repeater items, use the $w.at() function and pass it the context property of the event parameter:
$item = $w.at(event.context). To learn more, see here.
function onClick(handler: MouseEventHandler): Elementhandler: function MouseEventHandler(event: MouseEvent, $w: $w): void
The name of the function or the function expression to run when the element is clicked.
The element to which the event handler was added.
The mouse event that occurred.
This function does not return anything.
Was this helpful?