+ 1

How can I add the background image url from a loop of images ?

d.style.backgroundImage="url(images[0]+'.jpg' )";

19th Jul 2021, 7:15 PM
Francisco Bensaia
Francisco Bensaia - avatar
2 Answers
+ 5
You are already doing it but wrong syntax . Use template strings , d.style.backgroundImage=`url(${images[0]}.jpg)` or d.style.backgroundImage="url("+images[0]+".jpg)";
19th Jul 2021, 7:55 PM
Abhay
Abhay - avatar
+ 2
Thank you so much
20th Jul 2021, 12:47 PM
Francisco Bensaia
Francisco Bensaia - avatar