Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda