document.body.style.backgroundImage = "url('images[0]')";
I want to set the backgroundImage of the CSS body element as the image i have stored in image[0]
, however whenever I try to do so I get an error in the javascript console saying net::ERR_FILE_NOT_FOUND
.
I assume this is because it is looking for an image called 'images[0]'
which doesn't exist and so I get an error. How can I set it so that it reads the image that is actually stored in images[0]
?
Sorry if this has been asked before, I couldn't find any other questions like it when I looked.