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

149
Vistas
forEach link not appearing as clickable when fetching from Firestore

I have a forEach that will be showing a row of logos from firestore. I want these to be clickable with their url, both url and logo will be in the same document.

Im able to fetch and show all the logos but they are not clickable.

This is the code I use to get the foreach to show the logos.

const i = query(collection(db, "built"));
        const unsubscribe = onSnapshot(i, (querySnapshot) => {
            const team = document.querySelector('.built');

            querySnapshot.forEach((doc) => {
                const docData = doc.data();
                const teams = team.appendChild(document.createElement('built'));
                teams.innerHTML = `
                <a href="">
                <img class="logo">
                    <a/>
            `;
            teams.children[0].href = docData.url;
            teams.children[1].src = docData.logo;

                console.log("Current data: ", docData);
            });
        });

How do I create the url to be the link, and make each logo clickable?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

querySnapshot.forEach((doc) => {
    const docData = doc.data();
    team.innerHTML += `
      <a href="${docData.url}">
        <img src="${docData.logo}" class="logo" />
      </a>
    `;
});

or with document.createElement and logo div wrapper

querySnapshot.forEach((doc) => {
  const docData = doc.data();
  const link = document.createElement('a');
  const logo = document.createElement('img');
  logo.src = docData.logo;

  const logoWrapper = document.createElement('div');
  logoWrapper.classList.add('logo');
  link.href = docData.url;
  logoWrapper.appendChild(logo);
  link.appendChild(logoWrapper);
  team.appendChild(link);
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

I noticed a couple of things, not sure if that is causing your issue with the link not clickable.

'/>' instead of '>' for the image ending tag and '</a>' instead of '<a/>' for the anchor tag.

Try

<a href="">
   <img class="logo" />
</a>
about 4 years ago · Juan Pablo Isaza Denunciar
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