Search code examples
javascriptjquerytimercountdown

Display countdown using javascript or jquery


I want to display countdown in my html page, refreshing the page should not restart the countdown. Can anyone drop any example?


Solution

  • Use jquery.countdown.js

    This can be used as

     function setCountdown () {
    
        $('#countdown').countdown({until: +59, format: 'yowdHMS', 
                            layout: '{sn} {sl}', onExpiry: myFunction});
        $('#countdown').removeClass ('is-countdown');
        $('#countdownSpan').show ();
    }
    

    where the html would be

    <span id="countdownSpan">&nbsp;<span id="countdown"></span>seconds remaining</span>