Answers for "javascript update number"

0

javascript update number

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Video</title>
</head>
<body>
  <button> Add a Number </button>
  <div id="number_1">100</div>
  <div id="number">100</div>
  <script type="text/javascript">
    var count = 100;
    var count_2 = 100;
      function updateCount() {
       count = count - 1;
       if (count === 0) {
            count = 100
            function updateCount_2() {
             count_2 = count_2 - 1;
             document.getElementById("number_1").innerHTML = count_2 ;
            }
            updateCount_2();
       }
       document.getElementById("number").innerHTML = count;
       setTimeout(updateCount, 1);
      }

      updateCount();
  </script>
</body>
</html>
Posted by: Guest on October-18-2021

Browse Popular Code Answers by Language