Hello,
I am almost certain one of you guys will have a super quick solution
to this, but I just can't get it and it is doing my head in:
I have this piece of code which basically checks on client-side what
time of the day it is.
This information should be used to "use" different stylesheets based
on the time, e.g.
>=18 will be night.css
>=15 will be afternoon.css, etc.
however I cannot get to write this piece of html (e.g. <link
rel="stylesheet" href="night.css" type="text/css" media="screen"
title="night" charset="utf-8" />) by means of jquery.
I was able to set the class of <body> to either night, afternoon,
noon, etc, but I would rather like a solution where the time is
translated into night.css, afternoon.css, etc.
--- see code below ---
//date
datetoday = new Date();
timenow = datetoday.getTime();
datetoday.setTime(timenow);
thehour = datetoday.getHours();
if (thehour >= 18)
$('body').addClass('evening');
else if (thehour >= 15)
$('body').addClass('afternoon');
else if (thehour >= 12)
$('body').addClass('noon');
else if (thehour >= 7)
$('body').addClass('morning');
else if (thehour >= 0)
$('body').addClass('night');
else
$('body').addClass('general');
//end
Many thanks in advance for any suggestions and replies!
Any pointers or brain teasers welcome!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---