+ 1

javascript changing background image

how can i change the background image of an element using javascript?i use document.getElementById(id).style.backgroundImage = "url(" insert url "); but the url uses an https: and that causes an error with the javascript console

21st Jun 2018, 10:37 PM
Tence Sailor
Tence Sailor - avatar
2 Antworten
+ 3
Hi Tence Sailor have you tried using single quotes ' https' around the https?
21st Jun 2018, 10:52 PM
bobbie
bobbie - avatar
+ 3
Make sure that url its valid. If its, post your console error and your browser name... Test your code on other browsers just for test
21st Jun 2018, 11:49 PM
KrOW
KrOW - avatar