About Event Handlers in Wix

Event handlers in Wix work differently than in traditional web development. Normally, you would use addEventListener() to add event handlers, selecting DOM elements with methods like getElementById() or querySelector().

For example, you might write:

Copy

In Wix, however, you don’t access the DOM directly. Instead, you use the $w API to interact with elements in the Wix editor and add event handlers, like this:

Copy

Supported IDEs

You can use event handlers in the following IDEs:

  • The editor (Wix Studio and Wix Editor).
  • The Wix IDE (Wix Studio).
  • Your local IDE (Wix Studio and Wix Editor).
Important:

Wix event handlers are now dynamic. While static event handlers are still supported for existing sites, we recommend using dynamic event handlers for new development and when updating existing code.

See also

Was this helpful?
Yes
No