Update Number Since A Specific Date - jQuery Roughly

Update Number Since A Specific Date - jQuery Roughly
File Size: 44.9 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Roughly is a simple jQuery plugin to create an increasing counter that continuously updates an estimated number since a date you specify. With the ability to control variables such as increment step, interval time, decimal places, prefix, postfix and much more.

How to use it:

1. Include the Roughly plugin's script after you've included the latest version of jQuery JavaScript library.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="build/jquery.roughly.js"></script>

2. Initialize the plugin and specify the start date for your counter (optional).

$.fn.roughly.defaults = {
  startDate: 'January 1, 2015'
};

3. Create & config the counter with the following HTML data attributes.

  • data-start-date: start date
  • data-start-count: start number
  • data-wait-seconds: time in seconds to wait between updates
  • data-increase-by: increment step
  • data-decimals: number of decimals to display
  • data-prefix: prefix
  • postfix: postfix
<div data-wait-seconds="5" 
     data-increase-by="7.5" 
     data-decimals="1" 
     class="roughly">
</div>

4. You can also pass the options via JavaScript on init.

$("#myCounter").roughly({

  startDate: 'January 1, 1970',
  startCount: 0, 
  waitSeconds: 1, 
  increaseBy: 1, 
  decimals: 0, 
  prefix: '', 
  postfix: ''

});

This awesome jQuery plugin is developed by dahjson. For more Advanced Usages, please check the demo page or visit the official website.