Skip to content

Instantly share code, notes, and snippets.

@l4ci
Created January 9, 2018 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l4ci/66a749097dda81102521c6a1695a3206 to your computer and use it in GitHub Desktop.
Save l4ci/66a749097dda81102521c6a1695a3206 to your computer and use it in GitHub Desktop.
// <div class="counter" data-count="150">0</div>
$('.counter').each(function() {
var $this = $(this),
countTo = $this.attr('data-count');
$({ countNum: $this.text()}).animate({
countNum: countTo
},
{
duration: 8000,
easing:'linear',
step: function() {
$this.text(Math.floor(this.countNum));
},
complete: function() {
$this.text(this.countNum);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment