Animation Counter Javascript

Javascript code to display running count numbers
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Updated: 22 September 2022

The following javascript code serves to display a running calculated number. I use this script when helping the project that uses Oxygen Builder

Example results

Counter Animation


jQuery({ Counter: 4000 }).animate({
  Counter: jQuery('.counter').text()
}, {
  duration: 15000,
  easing: 'swing',
  step: function() {


 <p class="counter">2500</p>


counter: 4000 is the last number to go to, starting from the number we made, which is 2500.

.counter is a class that we add to the number as the target script marker.

duration: 15000 is the time it takes to finish the animation, which is 15000 ms or 15 seconds.

easing: swing is the animation model used (see: ).

.toLocaleString ('de') is a code to change numbers following the German standard (Deutsch), in this case what the client needs is separating thousands of numbers with dots. For the standard of other countries, the separator of the thousands is comma.

Animation Number Running On Specific Viewport

When working on, there is a need for animation to run if the section containing the number appears in the viewport because the position of the number is slightly down the page.

For that we use waypoint.js and CounterUp2.js to enable animation when the number/section is visible on the screen.

Counter Animation start from spesific point
<!-- load waypoint and counterup2 -->
<script src=""></script>
<script src=""></script>

<!-- html code -->
<span class="counter">9</span>
/** **/

jQuery( document ).ready( function() {
	jQuery(function ($) {
    	"use strict";
    	var counterUp = window.counterUp["default"]; // import counterUp from "counterup2"
    	var $counters = $(".counter");
    	/* Start counting, do this on DOM ready or with Waypoints. */
		$counters.each(function (ignore, counter) {
			var waypoint = new Waypoint( {
				element: $(this),
				handler: function() { 
					counterUp(counter, {
						duration: 5000,
						delay: 16
				offset: 'bottom-in-view',
			} );


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Article

Video Code using ACF Video Field
Solution of Jumping Modal Popups
I get this code from my client and also my friend 😊
Menu Accordion
I found this snippet code to create menu accordion from CodePen, but I did slightly modification from original code to […]
Digitalizer offers website design & development services for company profiles, online shops, event organizers, educational institutions or other fields. You don't need to think about domains, web hosting / servers, DNS, email, design, development, security and other technical issues. Just prepare your website content, we do the rest.
All website design & development packages include 1 year maintenance!
Free Consultation
Back to top