jQuery Number Counter On Scroll – Countup.js

Category: Text & Input | September 22, 2019
Author: AGMStudio
Official Page: Go to Website
Last Update:August 1, 2023

The Countup.js is a jQuery Number Counter On Scroll plugin that animates the numerical values by counting up from zero while the user scrolls down the page.

It’s a lightweight and tiny plugin which comes with a size of ~2kb only. The plugins come with nice features which include controlling the animation delay and transition.

By setting the configuration option, you can easily customize it as you want. Furthermore, It uses jQuery Waypoint plugin to trigger the count function when you scroll to a specific number.

In addition, the countup.js support the integers float and formatted numbers. You simply need to add the end number where you want to stop the counter.

Here is how you can define the numbers:

  • integers 12345
  • floats 0.1234
  • formatted numbers 1,234,567.00

How to Use jQuery Number Counter Plugin

To add the plugin into your project, you need to include the necessary jQuery and Way point library before closing the </head> tag.

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js"></script>

After that, make sure to Include the jQuery Countup.js script after jQuery.

<script src="jquery.countup.min.js"></script>

Now simply define the container and wrap the numerical values into span HTML element as follows.

<div class="counters">
    <span class="counter">300</span>
    <span class="counter">500</span>
    <span class="counter">800</span>

Finally, Initialise the Javascrption function and you will see the magic when you scroll down or up the page.


Configuration Option

The plugin offers you two different way to configure the options. You can either use the data attributes or can also define the options in the Javascrpoton function.

By using the data attribute you can easily set the time and delay by using the data-counter-time and data-counter-delay.

<span class="counter" 

If you don’t want to use the attribute then you can use the Javascript option to handle the timer and dealy.

  'time': 2000,
  'delay': 10

That’s it.

7 thoughts on “jQuery Number Counter On Scroll – Countup.js”

  1. hi nice work,
    the only problem I am having is that I keep getting an error :

    TypeError: null is not an object (evaluating ‘e.data(“counterup-nums”).shift’)

  2. Is there any way to conytrol it to count up only once. On initialising it using $(‘.abc’).countUp(), the count up executes each time when I scroll and the item became visible. I wan’t it to run only for the first time when the item became visible? After that no need to execute the count up.

Comments are closed.