A plugin make counter of an dom easy.
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>
the start number
the destination number
the duration of the counter to finish.
default is 0, if your want count like to 10.2, you should point it out as 1, otherwise it will counter with integer.
This support promise, like this:
var promise = $('#counter').countable('start').data('counter').$promise;
promise.then(function() {
console.log('finished');
});
Maybe, you can look at the demo directly.....
$ npm run test
MIT © lxpgw