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

133
Vistas
Dynamically update variable to hold window width that updates with event listener

I'm trying to make a carousel slider where my slide is as wide as the window, and I'm using the width of that slide to tell the other slides how far off screen they need to be. I'm trying to capture the window width dynamically so that when I resize the window, the width updates automatically without me being able to see the other slides. Can someone explain to me why I'm getting undefined here and tell me how to dynamically update this variable via event listener or otherwise?

let slideWidth;

window.onload = function () {
  slideWidth = window.innerWidth;
};

window.onresize = function () {
  slideWidth = window.innerWidth;
};

console.log(slideWidth);
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