Search.../

onFontChange( )

Adds an event handler that runs when an element's font value is changed.

Description

An element triggers a change event when a site visitor changes the font value in the panel element.

A change event is not triggered when you change an element's font value using the element's fontFamily property in code.

Because onFontChange() is fired before validations are performed, do not check any of the validation properties in the onFontChange() event handler. For example, do not code an if statement that checks the valid property in onFontChange() because the property at this point contains values prior to the onFontChange() event.

You can also define an event handler using the Properties and Events panel.

Syntax

function onFontChange(handler: EventHandler): Element
handler: function EventHandler(event: Event): void

onFontChange Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when the element's value changes.

Returns

The element on which the event is now registered.

Return Type:

EventHandler Parameters

NAME
TYPE
DESCRIPTION
event

The event that occurred.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Get the value of the element that was changed

Copy Code
1$w("#myElement").onFontChange((event) => {
2 let newFontValue = event.target.fontFamily; // "arial black"
3});