# LightqueryCollection#forEach

TIP

type ElementCallback<R = any> = GenericCallback<Element, R>;
declare function forEach(callback: ElementCallback): this;

This method enables you to execute a function on each element (e.g. to observe each element using an IntersectionObserver).

const observer = new IntersectionObserver(/* [...] */);
const $e = µ(/* [...] */);
$e.forEach(e => observer.observe(e));

NOTE: This is a replacement of jQuery's each method.

TIP

If your callback returns a value, it will be ignored.