Increasing count of number every second in javascript

I want counter, that increase or change the value of div every second using javascript or jquery.
Deepak Sharma
Asked 17-11-2024
2702

Answer (1)
Hey you can use it also. setTimeout(start, 1000); var i = 1; var num = document.getElementById("number"); function start() { setInterval(increase, 1000); } function increase() { if (i < 100) { i++; num.innerText = i; } }
Harsh Aggrawal
Asked 20-10-2019
45 Likes
Comments
Write comment

Answer (2)
hi here is solution in jquery: div value change upto 1000 or as per required <div class="count">    <span id="change_count">0</span>    <input type="hidden" id="count" value="1000"> </div> <script>     var s = 0;     var timer = setInterval(function () {         var count = (parseInt($('#count').val()) + 1);         if (count != s) {             $('#change_count').html(s++);         } else {             clearInterval(timer);         }     }, 1000); //here 1000milisec is equal 1sec. </script>
Ankur Rajput
Asked 20-10-2019
45 Likes
Comments
Write comment

Submit your answer