Answers for "how to make a countdown in javascript"

10

countdown in javascript

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8" />
      <title>Countdown timer using HTML and JavaScript</title>
   </head>
   <body>
      Registration closes in <span id="timer">05:00<span> minutes!

      <!-- custom js -->
      <script>
         window.onload = function () {
            var minute = 5;
            var sec = 60;
            setInterval(function () {
               document.getElementById("timer").innerHTML =
                  minute + " : " + sec;
               sec--;
               if (sec == 00) {
                  minute--;
                  sec = 60;
                  if (minute == 0) {
                     minute = 5;
                  }
               }
            }, 1000);
         };
      </script>
   </body>
</html>
Posted by: Guest on March-05-2021

Code answers related to "how to make a countdown in javascript"

Browse Popular Code Answers by Language