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

106
Vistas
forEach overlay showing the same content

I have a forEach showing a row of different images (fitness exercises) when you click on the image I want to show a clip of that exercise (gif).

But it doesn't show the same gif from the document of the image clicked on, it only shows the gif from the first document.

How do I make it so when you click on the image it shows the right gif from the same document.

I am collecting the image and gif from firestore.

Javascript Code

   const exgif = document.getElementById("exercise-gif");

                const e = query(collection(db, "user", uid, "yourWorkouts", id, "exercises"));
                const un = onSnapshot(e, (querySnapshot) => {

                    querySnapshot.forEach((doc) => {
                        // doc.data() is never undefined for query doc snapshots
                        console.log("exercises", doc.data());


                        const img = doc.data().image;
                        const exGif = doc.data().exGif;

                        exgif.innerHTML += `

                            <input type="image" id="toggle" src="${img}" class="ovr-ex-img" onclick="on()" />

                            <div id="over-exercise" onclick="off()">
                                <img class="ex-img" src="${exGif}">
                            </div>

                        `
                    });
                });  

function on() {
  document.getElementById("over-exercise").style.display = "block";
}

function off() {
  document.getElementById("over-exercise").style.display = "none";
}

HTML

<div class="" id="exercise-gif"></div>
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