[jQuery] Change background based of time of day using jquery
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=#FF') } //20-21 night if (hours 19 hours 22){ document.write('body bgcolor=orangered text=#FF') } //22-4 night if (hours 21 || hours 5){ document.write('body bgcolor=black text=#FF') } //9-17 day if (hours 8 hours 18){ document.write('body bgcolor=deepskyblue text=#FF') } //7-8 day if (hours 6 hours 9){ document.write('body bgcolor=skyblue text=#FF') } //5-6 day if (hours 4 hours 7){ document.write('body bgcolor=steelblue text=#FF') } /script
[jQuery] Re: Change background based of time of day using jquery
Thanks, I used the following: // change background depending on user's time 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'); On Sep 26, 7:51 am, Glen Lipka [EMAIL PROTECTED] wrote: Instead of document.write('body bgcolor=orange text=#FF') 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=#FF') } //20-21 night if (hours 19 hours 22){ document.write('body bgcolor=orangered text=#FF') } //22-4 night if (hours 21 || hours 5){ document.write('body bgcolor=black text=#FF') } //9-17 day if (hours 8 hours 18){ document.write('body bgcolor=deepskyblue text=#FF') } //7-8 day if (hours 6 hours 9){ document.write('body bgcolor=skyblue text=#FF') } //5-6 day if (hours 4 hours 7){ document.write('body bgcolor=steelblue text=#FF') } /script
[jQuery] Strip a href links from a div
Is it possible to strip links from a designated div with jquery? I've searched for a stripping mechanism, but haven't had any luck yet. I realize my request is pretty strange, I realize it'd be easier to not create links in the first place, but before I do that, I'm just curious about jquery's abilities.
[jQuery] Array of numbers in contains()
Hi, I'm appending a word to a number like so: $(.field-item:contains('25')).append(': Extreme'); My question is, given that the numbers 20-25 all should append 'Extreme', is there an easier way than doing the following? $(.field-item:contains('25')).append(': Extreme'); $(.field-item:contains('24')).append(': Extreme'); ... $(.field-item:contains('21')).append(': Extreme'); $(.field-item:contains('20)).append('': Extreme'); Maybe using an array or range function? Though I may be thinking too much like php.
[jQuery] Is it possible to show/hide a div with a class one at a time instead of all at once
Sorry for the vague subject, I rewrote it a few times and it still doesn't make much sense, hopefully what I say below does. I'm trying to implement jQuery into my comments to enable users to show/hide them as they read them. My problem occurs that using my current jQuery code, every comment div gets closed when clicking on one, while I would like it to only close the div the user clicks on. The comment itself is wrapped in a div class=comment/div while the Show/Hide links are within a ul in the div (explaining the not('ul') part of my code). My comment div looks something like this: div class=comment ulli class=show-comm-singlea href=# title=Show CommentShow/a/lili class=hide-comm-singlea href=# title=Hide CommentHide/a/li/ul div class=contentpcomment here/p/div /div And my jQuery code: $('li.hide-comm-single').click(function(){ $('.comment').children().not('ul').hide(); return false; }); With the current code, each comment on my page is hidden (so for example, if the page has 3 comments, and I only mean to click the first comment, but clicking it closes the other 2 comments as well). My question, is it possible to write the code so that 1 div class=comment at a time is closed instead of every one? Is there something I'm missing that allows just a unique .comment to be closed without having to use something silly like css ids.
[jQuery] Re: Is it possible to show/hide a div with a class one at a time instead of all at once
Awesome, it works! Thanks Sean, much appreciated. On Jun 14, 6:19 pm, Sean Catchpole [EMAIL PROTECTED] wrote: Try this: $('li.hide-comm-single').click(function(){ $(this).parents('.comment') .children().not('ul').hide(); return false; }); ~Sean