Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
GetBoundingClientRect is not a function when mapping array

I'm currently trying to write a script that will mute/pause video offscreen and play/unmute the ones on screen. The Ids of the different videos are mutable 1, mutable 2 etc.

In the code below I start of by getting the nodelist of all the ids beginning with mutable and change that into an array equal to the global variable 'nodelistToArray' when the page loads.

var nodelistToArray;
window.addEventListener('load', function() {
  nodelistToArray = [document.querySelectorAll('*[id^="mutable"]')];
})

Then I have a new function that runs when the user scrolls. Firstly I use .map to log all the values of the arrray into the console, this works fine. It logs this:

NodeList(2)
0:video#mutable1
1:video#mutable2

but then when I try to use getBoundingClientRect on each of the elements in the array it gives the error 'el.getBoundingClientRect' is not a function.

document.addEventListener('scroll', function() {
  nodelistToArray.map(el => console.log(el))
  nodelistToArray.map(el => el.getBoundingClientRect());

I have also tried doing getBoundingClientRect on just one query selector on its own and it works fine.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!