Answer the question
In order to leave comments, you need to log in
How to implement an infinite increase in numbers on the site in several blocks with one class?
How to make a number increase by 1 or any other, to infinity? the problem is that this needs to be done on the same page of the site for several blocks with a common class. The input and output values must be different. Those. starting number, say, for 4 blocks 100, 240, 50, 345 from them, each counter with its own block and starts counting.
Answer the question
In order to leave comments, you need to log in
let blocks = document.querySelectorAll('.foo')
setInterval(function(){
blocks.forEach(block => {
block.textContent = +block.textContent + 1
})
}, 500)
https://jsfiddle.net/32jufnm8/let blocks = $('.foo')
setInterval(function(){
blocks.each(function(){
this.textContent = +this.textContent + 1
})
}, 500)
https://jsfiddle.net/32jufnm8/1/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question