IntersectionObserverEntry: target property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Intersection Observer API")}}
The **target** read-only property of the {{domxref("IntersectionObserverEntry")}} interface indicates which targeted {{domxref("Element")}} has changed its amount of intersection with the intersection root.
Value
The IntersectionObserverEntry's target property specifies which {{domxref("Element")}} previously targeted by calling {{domxref("IntersectionObserver.observe()")}} experienced a change in intersection with the root.
Examples
In this simple example, each targeted element's {{cssxref("opacity")}} is set to its {{domxref("IntersectionObserverEntry.intersectionRatio", "intersectionRatio")}}.
function intersectionCallback(entries) {
entries.forEach((entry) => {
entry.target.style.opacity = entry.intersectionRatio;
});
}To see a more concrete example, take a look at Handling intersection changes.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}