onColorChange( )
Adds an event handler that runs when an element's color value is changed.
Description
An element triggers a change event when a site visitor changes the color value in the panel element.
A change event is not triggered when you change an element's color value using
the element's color
property in code.
Because onColorChange()
is fired before validations are performed, do not check
any of the validation properties in the onColorChange()
event handler. For example,
do not code an if
statement that checks the valid
property in onColorChange()
because the property at this point contains values prior to the onColorChange()
event.
You can also define an event handler using the Properties and Events panel.
Syntax
function onColorChange(handler: EventHandler): Elementhandler: function EventHandler(event: Event): void
onColorChange Parameters
NAME
TYPE
DESCRIPTION
The name of the function or the function expression to run when the element's value changes.
EventHandler Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
Was this helpful?
Get the value of the element that was changed
1$w("#myElement").onColorChange((event) => {2 let newColor = event.target.color; // "#FF4040"3});