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

182
Views
La galería no es interactiva al usar JavaScript y Css

He creado una galería que supone cambiar la imagen principal cuando se elige otra del menú pequeño de abajo, sin embargo, no reacciona cuando hago clic en otras fotos pequeñas, simplemente permanece igual, ¿alguien podría ayudarme?

 // image gallery const changeimage = (src) => { document.getElementById("main").src = src }
 .gallery { width: 90%; margin: 0 auto; } .gallery-main { width: 45rem; height: 30rem; margin: 0 auto; } .gallery-main img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23); } .gallery-p { display: flex; justify-content: center; flex-wrap: wrap; margin-top: 2rem; } .gallery-p img { width: 9rem; height: 7rem; object-fit: cover; border-radius: 4px; margin: 0.5rem; cursor: pointer; }
 <div class="gallery"> <div class="gallery-main"> <img src="images/dublin culture1.jpg" alt="" id="main"> </div> <div class="gallery-p"> <img src="images/dublin culture2.jpg" alt="" onclick="changeimage(this.src)"> <img src="images/dublin culture3.jpg" alt="" onclick="changeimage(this.src)"> <img src="images/dublin culture4.jpg" alt="" onclick="changeimage(this.src)"> <img src="images/dublin people1.jpg" alt="" onclick="changeimage(this.src)"> <img src="images/dublin people2.jpg" alt="" onclick="changeimage(this.src)"> <img src="images/dublin people3.jpg" alt="" onclick="changeimage(this.src)"> </div> </div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¡Prueba esto!

 document.getElementById("main").src = "https://i.ibb.co/2kfJ15Z/image-cropped.jpg" const changeimage = (src) => { document.getElementById("main").src = src }
 .gallery { width: 90%; margin: 0 auto; } .gallery-main { width: 45rem; height: 30rem; margin: 0 auto; } .gallery-main img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23); } .gallery-p { display: flex; justify-content: center; flex-wrap: wrap; margin-top: 2rem; } .gallery-p img { width: 9rem; height: 7rem; object-fit: cover; border-radius: 4px; margin: 0.5rem; cursor: pointer; }
 <div class="gallery"> <div class="gallery-main"> <img src="images/dublin culture1.jpg" alt="" id="main"> </div> <div class="gallery-p"> <img src="https://i.ibb.co/2kfJ15Z/image-cropped.jpg" alt="" onclick="changeimage(this.src)"> <img src="https://i.ibb.co/0GwkygJ/imagename-2.png" alt="" onclick="changeimage(this.src)"> <img src="https://i.ibb.co/2kfJ15Z/image-cropped.jpg" alt="" onclick="changeimage(this.src)"> <img src="https://i.ibb.co/0GwkygJ/imagename-2.png" alt="" onclick="changeimage(this.src)"> <img src="https://i.ibb.co/2kfJ15Z/image-cropped.jpg" alt="" onclick="changeimage(this.src)"> <img src="https://i.ibb.co/0GwkygJ/imagename-2.png" alt="" onclick="changeimage(this.src)"> </div> </div>

¡Gracias y un saludo!

about 4 years ago · Juan Pablo Isaza Report
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!