Intersection Observer Does not get all the IDS

So i am lazy loading my images (lazy load is done by another script)

now as the divs and imgs lazy load, i am using intersection observer to get the ids, but it only gets first 6 ids and does not the rest of them, Please help


const targets = [...document.getElementsByName('item-id')];
const options = { };

let clickedId_test;

const observer = new IntersectionObserver(function(entries, observer)
entries.forEach(entry => { 
if (!entry.isIntersecting) { 

clickedId_test = 


targets.forEach(like_button => { 

Pics to See whats Happening

Hi there!

Well, I’m not sure if I fully understand the usage cause I don’t have the full code context. But I wonder why are you using the Intersection to get the ids?
Either way, it seems that maybe the entries are not changing from id 5, for some reason, or the logic you’ve written is not matching the cases from 5 on.

Here’s a resource that could help you: Learn Intersection Observer In 15 Minutes - YouTube :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.