OnClick evemt

You need to use the correct Wix Code syntax with the appropriate Wix Code APIs.

import wixLocation from "wix-location";

$w("#button1").onClick( (event, $w) => {
    wixLocation.to("http://www.google.com/");
} );

Some points to keep in mind:

  • The Button API uses onClick() as its click event handler - not click()

  • An element ID includes a hashtag as shown in the example. “#button1” and not “button1”.

  • Wix Code doesn not allow access to the window DOM element. You can redirect using the wix-location.to() API.
    Refer to the Wix Code documentation for more information.

Good luck,

Yisrael