Skip to content

A jQuery plugin that will count up (or down) to a target number at a specified speed.

Notifications You must be signed in to change notification settings

jmaclabs/jquery-countTo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

jQuery countTo Plugin

jQuery countTo is a jQuery plugin that will count up (or down) to a target number at a specified speed, rendered within an HTML DOM element.

Requirements:

jQuery countTo requires the latest version of jQuery.

Usage:

The most basic usage of this plugin is to create a DOM element, and apply the countTo method to it in your JS.

<script type="text/javascript"><!--
    $('.timer').countTo({from: 0, to: 500});
//--></script>

<span class="timer"></span>

A more detailed example that demonstrates all possible options being used is as follows.

<script type="text/javascript"><!--
    $('.timer').countTo({
        from: 50,
        to: 2500,
        speed: 1000,
        decimals: 2,
        commas: true,
        refreshInterval: 50,
        onComplete: function(value) {
            console.debug(this);
        }
    });
//--></script>

<span class="timer"></span>

Options:

A complete listing of the options that can be passed to the countTo method is below.

Option Description
from The number to start counting from.
to The number to stop counting at.
speed The number of milliseconds it should take to finish counting.
decimals The number of decimal points to use.
commas Whether to show commas in formatted number.
refreshInterval The number of milliseconds updating the count.
onComplete A callback function the is triggered when counting finishes. The final value is passed to the function, and it is run in the context of the DOM element

Created By:

Matt Huggins

Modified By:

Andrew Herron

License:

jQuery-countTo is released under the MIT license.

About

A jQuery plugin that will count up (or down) to a target number at a specified speed.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published