Update - Already caught one issue. Was simply my stupid mistake. How do I add a function to make this code rerun itself for each time block, so it updates on an open browser? - Thanks
I am trying to have a simple gallery of images (For example 20 images, 15 sec each, scrolling indefinitely), but all the images will change based on the time of day. For example: 8am-11am one set, 12pm-4pm another, 4-8pm, and 8pm-7am. I have been messing with this from existing code I have found, and tried a ton of versions, but none have worked.
This is the code idea I am messing with (not working), but maybe I should be going about this entirely differently. Thoughts?
(example of different time blocks, and only with 3 images - but doesn't work)
$(document).ready(function(){
var d = new Date();
var n = d.getHours();
// If time is after 8PM or before 7AM
if (n > 20 || n < 7) {
$("img#photo1").attr("src","img/8TO7/photo1.jpg");
$("img#photo2").attr("src","img/8TO7/photo2.jpg");
$("img#photo3").attr("src","img/8TO7/photo3.jpg");
}
else if (n > 16 && n < 20) {
$("img#photo1").attr("src","img/4TO8/photo1.jpg");
$("img#photo2").attr("src","img/4TO8/photo2.jpg");
$("img#photo3").attr("src","img/4TO8/photo3.jpg");
}
else {
$("img#photo1").attr("src","img/main/photo1.jpg");
$("img#photo2").attr("src","img/main/photo2.jpg");
$("img#photo3").attr("src","img/main/photo3.jpg");
}
});