Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda