Answer the question
In order to leave comments, you need to log in
Animated number change in real time?
The page has a div that contains a number. This number is added from the php file (using include), and the number gets into the php file from the database. DB>>>php-file>>>page. The div that contains the number is updated every 3000ms.
With this code, the number on the page is animated: (the number is counted from 1, for example, 1,2,3,4 and until the number itself is displayed)
$(window).scroll(startCounter);
function startCounter() {
if ($(window).scrollTop() > 3000) {
$(window).off("scroll", startCounter);
$('.Count').each(function () {
var $this = $(this);
jQuery({ Counter: 0 }).animate({ Counter: $this.text() }, {
duration: 4000,
easing: 'swing',
step: function (now) {
$this.text(now.toFixed(2));
}
});
});
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question