Search code examples
javascriptjquerycountdown

jquery countdown.js relative example


I'm trying to learn javascript and looking add countdown given here http://keith-wood.name/countdown.html#relative (Until 300 seconds time example) I'm trying it for couple of hours now - still didn't get it working.

created jsfiddle here http://jsfiddle.net/lakshmipathi/5gYtZ/1/

css file

<link rel="stylesheet" type="text/css" href="http://giis.co.in/jsfiles/jquery.countdown.css">

js file

<script type="text/javascript"  src="jquery.min.js"> </script>
<script type="text/javascript" src="jquery.plugin.js"> </script>
<script type="text/javascript" src="jquery.countdown.js"> </script>
// Fires once
$(document).ready(function(){
  $('#timer').countdown({until: +300, format: 'dHMS'});
});

html file

<div id="timer"> </div>

Thanks for any help!

countdown works after fixing issues noted by Rory McCrossan. http://jsfiddle.net/5gYtZ/4/

Just one final question on it, How to reduce the length of the output?


Solution

  • Just one final question on it, How to reduce the length of the output?

    If I've understood what you mean, that's because the contents of #timer are floated. You need to make the element overflow: hidden so that it's bounds are calculated correctly:

    #timer {
        overflow: hidden;
    }
    

    Updated Fiddle