jQuery countdown timer for minutes and seconds

0 votes

I want create a jquery countdown timer, i tried as the following code but it does not work.what do i do?

DEMO: https://jsfiddle.net/tbosn210/

var interval = setInterval(function() {
    
    var timer2 = $("5:01");
    var timer = timer2.split(':');
    //by parsing integer, I avoid all extra string processing
    var minutes = parseInt(timer[0],10);
    var seconds = parseInt(timer[1],10);
    --seconds;
    minutes = (seconds < 0) ? --minutes : minutes;
    if (minutes < 0) clearInterval(interval);
    seconds = (seconds < 0) ? 59 : seconds;
    seconds = (seconds < 10) ? '0' + seconds : seconds;
    //minutes = (minutes < 10) ?  minutes : minutes;
    $('.countdown').html(minutes + ':' + seconds);
}, 1000);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="countdown"></div>

Aug 12 in Web Development by gaurav
• 18,960 points
148 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Web Development

0 votes
0 answers
0 votes
0 answers

jQuery Count Down timer based on Remaining Days, Hours, Minutes and Seconds

I'm creating a system where I have ...READ MORE

Aug 11 in Web Development by gaurav
• 18,960 points
138 views
0 votes
0 answers

How Can I create A 5 second Countdown timer with jquery that ends with a login popup?

How would i create a jquery timer ...READ MORE

Jul 28 in Web Development by gaurav
• 18,960 points
36 views
0 votes
0 answers

jQuery show for 5 seconds then hide

I'm using .show to display a hidden ...READ MORE

Jul 29 in Web Development by gaurav
• 18,960 points
37 views
0 votes
0 answers

Using jQuery to countdown from 90 seconds beginning on the click of an element

Hi I was wondering if anyone can ...READ MORE

Aug 22 in Web Development by gaurav
• 18,960 points
20 views
0 votes
0 answers

How to start Airbnb Clone for Movies and Events Booking Website?

Instant #Online Movies and Events Ticket Booking ...READ MORE

Feb 17, 2020 in Web Development by Bessie
• 160 points

reshown Feb 18, 2020 by Gitika 445 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,510 points
322 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,780 points
9,279 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,780 points
16,449 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,780 points
1,413 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP