.off(type?, fn?)
Available on: InDom, InDomArray

Removes event listener(s) registered with .on() or its shorthand methods.

Parameters:
type {string} (optional) - Event type. If omitted, all listeners are removed.
fn {Function | Function[]} (optional) - Handler(s) returned by .on(). If omitted, all listeners of type are removed.

Returns: {InDom | InDomArray} - this for chaining

Throws:
TypeError - If type is provided but is not a non-empty string.
RangeError - (InDomArray only) If fn array length does not match collection length.
Error - If the underlying element has been removed

Examples:
const divs = $a('.example>div');

divs.onClick(n => {
	console.log(n);
	/*
		this function is visible in DevTools: 
		#events / click / Set entry / [[TargetFunction]]
	*/
});

// a simple logger example 
divs.onEnter(n => console.log(`onEnter in:${n.getHtml()}`));

const addOnFns = divs.onEnter(n => n.addClass('on'));
const removeOnFns = divs.onLeave(n => n.removeClass('on'));

// remove addOnFns and removeOnFns but keep the first onEnter logger
divs.off('mouseenter',addOnFns).off('mouseleave',removeOnFns);

// remove every mouseenter handler (including the logger)
divs.off('mouseenter');

// remove every handler of every type (including onClick)
divs.off();
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.