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

156
Vistas
I want to change css background url by javascript

I want to change the background url of image by javascript now in other tutorials they have the image downloaded in the desktop and just give its path but in my case the user will give a image link in input area and it should display inside of that url

let imglink = document.getElementById("img_link").value
document.getElementById("imgPreview").style.backgroundImage = 'url(' + imglink + ')'

I know my code is wrong and weird but I need proper solution how i can put that link inside that url. PLEASE dont do too much hard coding bcz I am a beginner it will hard for me to understand

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

0

Change

'url(' + img_link + ')'

to

'url("' + img_link + '")'
about 4 years ago · Juan Pablo Isaza Denunciar

0

Does this work?

document.getElementById("imgPreview").style.backgroundImage = url(img_link)

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