.each(fn)
Available on: InDomArray

Executes a function for each InDom object in the collection.

Parameters:
fn {(n: InDom, index: number, array: InDomArray) => void} - Function to execute

Returns: {InDomArray} - this for chaining

Examples:
$a('.example>div').each(n => {
  if (!n.hasData('init')) {
    // one-time initialisation
    n.setData('init', 1);
  }
});
// .each() is safe on empty collections: the callback simply never runs
Next: filter »
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.