Skip to content

lxpgw/jquery-countable

Repository files navigation

jquery-countable

A plugin make counter of an dom easy.

Getting Started

Download the production version or the development version.

In your web page:

<script src="jquery.js"></script>
<script src="dist/jquery-countable.min.js"></script>
<script>
  jQuery(function ($) {
    $('#counter').countable({
      from: 0,
      to: 100,
    });
  });
</script>

APIs

from

the start number

to

the destination number

duration

the duration of the counter to finish.

decimals

default is 0, if your want count like to 10.2, you should point it out as 1, otherwise it will counter with integer.

Promise

This support promise, like this:

var promise = $('#counter').countable('start').data('counter').$promise;
promise.then(function() {
  console.log('finished');
  });

Demo

Maybe, you can look at the demo directly.....

Test

$ npm run test

License

MIT © lxpgw