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

185
Views
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
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!