Reputation: 928
I see these countdown plugins and countdown snippits for 5 seconds. But I am looking to use jquery, with out additional plugins to crate a 30 minute timer that changes the text inside of a h2 tag to count down:
<h2>30m</h2> .... <h2>29m</h2> //and so on.
How would this be achieved? After the countdown it should do something.
Upvotes: 0
Views: 44
Reputation: 408
The h2 should contain the initial minutes value, like "30". The code will look like:
$(document).ready(function() {
setInterval(function() {
min = parseInt($('h2').text()) - 1;
$('h2').html(min);
if (min == 0) {
// Do Something
}
}, 60000);
});
Upvotes: 3