Show or hide date based content with jQuery?

I want some content on my page (some images) to change depending on the date. With jQuery, how is this possible?

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

I was able to do this with ColdFusion for another client, but I don't know how to do it with jQuery. Any help POSSIBLE is much appreciated.

+3
source share
2 answers

Example, check if the date after Christmas is indicated. You must set div_id to display: none; originally. You can change the selector to an identifier, a class, or whatever 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();
}
+5
source

Source: https://habr.com/ru/post/1772191/


All Articles