Skip to content

Editor / DOM Helper / watchInput

Function: watchInput() ​

ts
function watchInput<T>(
   selectors, 
   callback, 
   opt?): void;

Watches for changes on input elements and triggers a callback with the updated values.

  • Supports single or multiple selectors.
  • Calls the callback every time an input event occurs on the specified elements.

Type Parameters ​

Type ParameterDefault type

T

any

Parameters ​

ParameterTypeDescription

selectors

string | string[]

A single selector string or an array of selector strings.

callback

(values) => void

A function to call with the updated values of the inputs.

opt

{ additionalEvents: keyof HTMLElementEventMap[]; }

‐

opt.additionalEvents

keyof HTMLElementEventMap[]

‐

Returns ​

void

Example ​

ts
watchInput('$input-id', (values) => console.log(values));
watchInput(['$input-1', '$input-2'], (values) => console.log(values));

Version v2.0.0-beta.2 - Built on 2026-08-22