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

178
Views
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
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!