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:
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:
You can use event handlers in the following IDEs:
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.