Skip to content Skip to sidebar Skip to footer

Image Display Based On Time

I'm trying to create an image rotator that displays certain images at certain times, but also rotates at other times in the day. When I first created it, I just had it rotate ever

Solution 1:

first of all, all your variables seem to be are global, please dont do that, use an anonymous function-wrapper which executes your code (immediately (read about IIFE here. this is not part of your problem, but just good and clean coding style.

(function() {
  // your code here
})();

then i think one of your problems is your displayImages-function, which you declare but never call!

just should call it at the end of your code (or just leave it out)

displayImages();

if you want your images not to be swapped between 10-12 and 17-19 your code should then work as expected. if the images should swap even at this times, you shouldnt put the setInterval into the last else (inside your displayImages-function

Post a Comment for "Image Display Based On Time"