开发者

Show or hide content based on the date with jQuery?

I want to have some content on my page (some images) change based on the date. With jQuery, how would this be possible?

Basically, I am leaving on vacation and my client needs something to change while I'm unavailable.

I've been able to do it with ColdFu开发者_高级运维sion for another client, but I don't know how to do it with jQuery. Any help is GREATLY appreciated.


Example, check if Date is after Christmas. The div_id needs to be set to display:none; initially. You can change the selector to an id, class, or whatever else you need.

var now = new Date();

var Christmas = new Date("December 25, 2010");

if(now > Christmas) // today is after Christmas
{
     // an id of a div that holds your images?
     $('#div_id').show();
     // or a class of images
     $('.imageClass').show();
}


Have a look here for Date object: http://www.w3schools.com/jsref/jsref_obj_date.asp

based on date just change/manipulate images

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜