C
C
carbanak012020-05-11 14:17:50
JavaScript
carbanak01, 2020-05-11 14:17:50

Why does it return an error when trying to find out getBoundingClientRect in forEach?

const circles = document.querySelectorAll('<класс>');
window.addEventListener('scroll', ()=>{
    circles.forEach((circle)=>{
    console.log(circle.getBoundingClientRect());
});
});

on a for loop works

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Neuro, 2020-05-11
@Riveran

the circles collection does not have a forEach method, to iterate try using the for of statement

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question