jquery Countdown

Here’s a simple way to add a countdown to your website.

Quick overview

1. Link these javascript libraries to your html page.

<script src="http://https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://cdn.rawgit.com/hilios/jQuery.countdown/2.0.4/dist/jquery.countdown.min.js"></script>

2. Add the following script to your page.

<script type="text/javascript">
$('#jcountdown').countdown('2016/01/01 00:00:00', function(event) {
    var $this = $(this).html(event.strftime(''
      + '<span>%-D</span> days '
      + '<span>%H</span> hr '
      + '<span>%M</span> min '
      + '<span>%S</span> sec'));
  });
</script>

3. Create a div with id=”jcountdown” and style it the way you would like. (see sample on jsfiddle above)

Leave a comment

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

2 × 1 =