Instead of document.write('<body bgcolor="orange" text="#FFFFFF">') Use $("body").css("background-color","blue") or $("body").addClass("noon")
I think the time part could potentially be a switch, but that's just readability. Glen On 9/25/07, bsuttis <[EMAIL PROTECTED]> wrote: > > > I'm curious if I could use jquery to change my body's background based > on time of day. I'm not looking to do this server-side with php, I > would like the background to change based on the visitor's time, not > the server's. > > I've found this code, just wondering if I can jquery-ize: > <script> > var now = new Date(); > var hours = now.getHours(); > var psj=0; > > //18-19 night > if (hours > 17 && hours < 20){ > document.write('<body bgcolor="orange" text="#FFFFFF">') > } > > //20-21 night > if (hours > 19 && hours < 22){ > document.write('<body bgcolor="orangered" text="#FFFFFF">') > } > > //22-4 night > if (hours > 21 || hours < 5){ > document.write('<body bgcolor="black" text="#FFFFFF">') > } > > //9-17 day > if (hours > 8 && hours < 18){ > document.write('<body bgcolor="deepskyblue" text="#FFFFFF">') > } > > //7-8 day > if (hours > 6 && hours < 9){ > document.write('<body bgcolor="skyblue" text="#FFFFFF">') > } > > //5-6 day > if (hours > 4 && hours < 7){ > document.write('<body bgcolor="steelblue" text="#FFFFFF">') > } > </script> > >