Quolo21
Quolo21

Reputation: 21

jQuery: How to make my countdown automatically restart?

I have a jQuery countdown that starts at 60 minutes, and when it ends - it will show an alert "end!".

Instead of it showing this alert, I would like the timer to restart itself back to 60 minutes. Here is my code:

<script type="text/javascript">

    $(function(){
        $('#counter_2').countdown({
          image: 'img/digits.png',
          startTime: '60:00',
          timerEnd: function(){ alert('end!'); },
          format: 'hh:ss'
        });
    });

</script>

I have no idea what I am doing, and have little to no knowledge on js/jquery. Thanks in advance!

Upvotes: 2

Views: 600

Answers (2)

Arun P Johny
Arun P Johny

Reputation: 388316

Try

function doTImeStuff() {
    $('#counter_2').countdown({
        image : 'img/digits.png',
        startTime : '60:00',
        timerEnd : function() {
            setTimeout(doTImeStuff)
        },
        format : 'hh:ss'
    });
}

Upvotes: 2

Ben McCormick
Ben McCormick

Reputation: 25718

var params = {
          image: 'img/digits.png',
          startTime: '60:00',
          format: 'hh:ss'
        };

function start(){
  $('#counter_2').countdown(params);
}


setInterval(start,60000)

Upvotes: 0

Related Questions