.setValue(value, container?)
Available on: InDom, InDomArray

Sets the element’s value, normalised for its type (see getValue()).

Parameters:
value {string | string[]} - Value(s) to assign
container {Document|Element|InDom} (optional) - Scope for checkbox and radio group lookups. When provided, only searches within this container for related elements. Defaults to document.

Returns: {InDom | InDomArray} - this for chaining

Throws:
TypeError - If the element has no writable value
Error- If the underlying element(s) has been removed

Examples:
// single text input
$1('[name="username"]').setValue('Bob');

// multiple select
$1('[name="size"]').setValue(['m','l']);

// check only 'gps' in this container (other containers ignored)
const div = $1('.input-examples');
$1('[name="features"]', div).setValue('gps', div);
// a single value can be set with a string or a one-item array

// clear all editable fields
$a('input, textarea, select').setValue(null);
Next: on »
Modern DOM Power
for TypeScript, ESM & Plain JS
3.8KB JavaScript library that simplifies DOM manipulation
with a clean, chainable API for events, data, inputs harvesting, and more.
Automatic Cleanup,
Leak-Proof by Design
Events and state are cleared when elements leave the DOM,
even if removal happens outside InDom.
Cleaner Code,
Better Ergonomics
Get the InDom object directly in callbacks.
One element, one instance.
Works With Your Existing Stack
Use InDom on its own or alongside any library or framework,
its architecture ensures a seamless integration.