Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A CountUp extension for jQuery
// Dependency: CountUp.js:
(function ($) {
$.fn.countup = function (params) {
// make sure dependency is present
if (typeof CountUp !== 'function') {
console.error('countUp.js is a required dependency of countUp-jquery.js.');
var defaults = {
startVal: 0,
decimalPlaces: 0,
duration: 2,
if (typeof params === 'number') {
defaults.endVal = params;
else if (typeof params === 'object') {
$.extend(defaults, params);
else {
console.error('countUp-jquery requires its argument to be either an object or number');
this.each(function (i, elem) {
var countUp = new CountUp(elem, defaults.endVal, defaults.options);
return this;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.