so I have an array, containing titles and covers for movies. I'm trying to display the names in the flexbox, using cover image as background image.
I also tried to write it like that: document.div.style.backgroundColor = "url(infoForThatDay[each]['cover'])"; but it didn't work either
Here is the snippet of my code:
for(let each in moviesToDisplay) {
let div = document.createElement("div")
div.innerText = moviesToDisplay[each]['title'];
//That is where I'm trying to set the background color
div.style.backgroundColor = "url(moviesToDisplay[each]['cover'])";
flex.appendChild(div);
}
Thank you in advance <3 have a great day ^_^
"url(infoForThatDay[each]['cover'])"so that the expression is evaluated and not used literally as the background color.url()if it's an image value.