change event (also called code event) is fired when the playground “content” changes.
Event Payload
The event callback receives an object with the following structure:An object containing the language, content and compiled code for each editor.
The current configuration object.
When It Fires
Thechange event is triggered when any of the following changes:
- Code in any editor (markup, style, or script)
- Editor languages
- CSS processors
- External resources
- Project info (e.g. content in page head, attributes to
<html>element) - Custom settings (e.g. import maps)
- Project title
- Test code
Usage Example
Common Use Cases
Auto-Save on Changes
Track Code Statistics
Mirror Code to Another Element
Check Compiled Output
Sync with External Editor
Using onChange() (Deprecated)
The onChange() method is deprecated. Use watch("code", ...) instead: