I have made an array with a set of random images which works. I just don't know how I'm supposed to style the image as an image;
var imageURLs = [
"./images/404/random1.png"
, "./images/404/random2.png"
, "./images/404/random3.png"
, "./images/404/random4.png"
, "./images/404/random5.png"
];
function getImageTag() {
var img = '<img src=\"';
var randomIndex = Math.floor(Math.random() * imageURLs.length);
img += imageURLs[randomIndex];
img += '\" alt=\"404 Image."/>';
img.className = "404image";
img.width = "10%"
return img;
}
document.write(getImageTag());
I'd assume you'd style it with the class name but I can't make .404image
work for styling in CSS.
Any ideas? Thanks in advance, really stuck.