Web Design Tutorial – Christmas Countdown using Jquery

Posted on Tuesday 13th Dec 2011 by Luci Smethurst 2 Comments

This week I stumbled across an really great project on Github, where folks are working on a jQuery countdown. Aside from the obvious use for the countdown ’til Santa comes down the chimney, it could also be put to great use on ecommerce websites as countdowns until the end of sales and/or special offers.

I’ll be putting it to use in a web design shortly!

Countdown
It’s really easy to use, and you have the choice of appointing a time to start (and countdown from) or set a date for it to end.

Which ever option you want to go with, you’ll need to include the jQuery library and the Countdown Code:


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="/countdown.js"></script>

To set a date (like Christmas Day!), you need to set a variable:

var _date = new Date();
_date.setMonth(11);
_date.setDate(25);
_date.setHours(09);
_date.setMinutes(0);
_date.setSeconds(0);

It’s important to note, with regards to the date, that the Javascript setMonth method starts at zero – January = 0, February = 1 and so on until December, which is 11.

After that it’s as simple as defining your image! There are other options as well, which you can find on the GitHib page. Enjoy!

$('#counter').countdown({
            startTime: _date,
            stepTime: 1
            image: "/digits.png"
        });

About Luci Smethurst

Luci likes geeky things, green things, and chocolate. That pretty much sums her up, really.

See all of posts.

Add on Luci Smethurst Google+

Luci Smethurst's Tweet's

  • @missrachilli hold out! you can do it -strepsil it up! Go by the 3 day rule - day 1: bad; day 2: awful; day 3: (a bit) better :) Less than 1 minute ago!
  • RT @daniel_c_long: Cool Photoshop action to remove gradient banding http://t.co/XQ2lUZoj via @brdrck Less than 1 minute ago!
This entry was posted in JavaScript Tutorials and tagged , , , . Bookmark the permalink.

2 Responses to Web Design Tutorial – Christmas Countdown using Jquery

  1. James Bavington says:
    December 15, 2011 at 8:44 am

    Awesome script Luci, Would be useful for counting down Christmas Sales too, play.com use something similar in the run-up to Christmas for their daily deals.

  2. Gavin says:
    December 16, 2011 at 3:27 pm

    Ahh I wish I had this a few weeks ago when making http://www.webtemplates-creare.com/

    Good work though Luci!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>