Function: onChange()
Overload 1
onChange(
element,callback):void
Defined in: interaction.ts:92
Registers a callback to be invoked when the value of the given form field changes.
Parameters
element
The target form field element.
callback
The function to call when the value changes.
Returns
void
Example
// HTML
<input id="username" type="text" />
// JS
const input = facile.getElement('#username');
facile.onChange(input, (value) => facile.say(`Hello, ${value}!`));Overload 2
onChange(
tag,callback):void
Defined in: interaction.ts:105
Registers a callback to be invoked when the value of the first form field matching the given tag name changes. Does nothing if no element is found.
Parameters
tag
"input" | "select" | "textarea"
The HTML tag name of the form field to search for.
callback
The function to call when the value changes.
Returns
void
Example
// HTML
<input type="text" />
// JS
facile.onChange('input', (value) => facile.say(`Hello, ${value}!`));Overload 3
onChange(
selector,callback):void
Defined in: interaction.ts:121
Registers a callback to be invoked when the value of the first form field matching the given CSS selector changes. Does nothing if no element is found.
Parameters
selector
string
A CSS selector string.
callback
The function to call when the value changes.
Returns
void
Example
// HTML
<input id="username" type="text" />
// JS
facile.onChange('#username', (value) => facile.say(`Hello, ${value}!`));