Search...
onClick( )
Adds an event handler that runs when the element is clicked.
Description
An element receives a click
event when a user clicks on the element
and releases.
You can also define an event handler using the Properties and Events panel.
This will automatically add the required code for the selected element and event:
javascript | Copy Codeexport function button1_click(event) {// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4// Add your code for this event here:}
Syntax
function onClick(handler: EventHandler): Elementhandler: function EventHandler(event: Event): void
onClick Parameters
NAME
TYPE
DESCRIPTION
handler
The name of the function or the function expression to run when the element is clicked.
EventHandler Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
Open a dashboard panel when the user clicks a button
Copy Code
1import wixEditor from 'wix-editor'23$w.onReady(function () {4 $w('#myButton').buttonLabel = "Manage Contacts"; // Set the button's label5 $w('#myButton').onClick(async () => {6 await wixEditor.openDashboardPanel({ url: "/contacts" }) // Open the site Dashboard's Contacts page7 })8});