.setHtml(content)
Available on: InDom, InDomArray

Sets the innerHTML of the underlying element(s).

Parameters:
content {string} - Content to insert (coerced to string)

Returns: {InDom | InDomArray} - this for chaining

Throws:
Error - If the underlying element(s) has been removed

Note:
setHtml inserts raw HTML. Use it with trusted strings; sanitize any user-provided content before calling it.

Examples:
const div1 = $1('.example>div');

//set onClick on the every span child of div1
$a('>span', div1).onClick(n => console.log('clicked', n));


//replace innerHTML → old spans gone, listener gone
div1.setHtml('<span>another test</span>');

// re-register on the new span(s):
$a('>span', div1).onClick(n => console.log('clicked', n));

// or:
div1.onClick((_, e) => {
	const span = $n(e.target).getSelfOrParent('.example>div>span');
	if (span) {
		console.log('clicked', span);
	}
});
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.