0

I want to change the image src in my header with the class name custom-logo to load one of those images in my array on a page reload. This doesn't seem to be working:

var images = [
  'Logo-1.jpg',
  'Logo-2.jpg',
  'Logo-3.jpg',
  'Logo-4.jpg'
]

var which = Math.floor(Math.random() * images.length);
var img = document.getElementByClassName('custom-logo');
img.src = images[which];
Satpal
  • 132,252
  • 13
  • 159
  • 168
Demonix
  • 33
  • 1
  • 6

0 Answers0