Changing background based on time of day (using javascript)

I’d recommend something slightly different than neo – rather than setting the image only, have two CSS classes, one for day and one for night – both can be in the same stylesheet. You can set the body’s class depending on the time of day. This will allow you to do more than just the background.

document.body.className = "day";
document.body.className = "night";

Leave a Comment