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

181
Vistas
Dynamic images responsives SRCSET

I have a problem with responsive images especially when they have an ID.

<IMG SRCSET="images/portfolio/vide.jpg 30w, images/portfolio/vide.jpg 100w" 
SIZES="(min-width: 400px) and (max-width: 640px) 30px, (min-width: 641px) and (max-width: 800px) 30px, (min-width: 801px) 100px" SRC="images/portfolio/vide.jpg" ID="Photos3D" />

I want to change the image with JS.

document.getElementById("Photos3D").srcset="images/portfolio/3d/"+Photo[Nbr]+".jpg 30w, images/portfolio/3d/"+Photo[Nbr]+".jpg 100w";

Photo[Nbr] is equal to 001 so the link is "images/portfolio/3d/001.jpg" (I tested with alert(Photo[Nbr]); and I have 001 in the window.)

But the image still remains at "images/portfolio/vide.jpg", it does not change. I think the document.getElementById("Photos3D").srcset is wrong but I don't know how to use it dynamically.

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