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

188
Vistas
Problems with backgroundImage, backtick and interpolation

I am trying to change the div images in a way that respects the city name. I was thinking of taking these' images and calling them "image1.jpg" and so on.

I don't understand why even though the url is correct (looking at the console log). [console.log][1]

Javascritpt

        
         //CHANGE IMAGE
        let divFoto = document.querySelectorAll('.viaggi-foto');
        for(let i = 0; i < divFoto.length; i++){
            divFoto[i].style.backgroundImage = `"url('../img/luogo${divFoto[viaggio.id]}.jpg')"`;
            divFoto[i].style.backgroundSize = 'cover';
            divFoto[i].style.backgroundPosition = 'center';
            console.log("bg: ", divFoto[i].style.backgroundImage);
        }
    });

   
}

Css

  .viaggi-foto{
    height: 50%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    background-image: "";
  }


  [1]: https://i.stack.imgur.com/w2L94.png
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