Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

207
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda