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

189
Views
Problemas con backgroundImage, backtick e interpolación

Estoy tratando de cambiar las imágenes div de una manera que respete el nombre de la ciudad. Estaba pensando en tomar estas imágenes y llamarlas "image1.jpg" y así sucesivamente.

No entiendo por qué a pesar de que la URL es correcta (mirando el registro de la consola). [consola.log][1]

Javascript

 //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!