I want counter, that increase or change the value of div every second using javascript or jquery.
Deepak Sharma
Asked 20-12-2024
2714
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
Submit
Answer (2)
hi here is solution in jquery: div value change upto 1000 or as per required
0
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.