A jQuery plugin for incrementing and decrementing values
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.textile
jquery.increment-decrement.js

README.textile

jQuery Increment/Decrement Plugin

This plugin allows you to easily increment and decrement values with jQuery.

Examples

We’ll use this HTML as a base for all the following examples:


<html>
  <head>
    <script src='/javascripts/jquery.increment-decrement.js' type='text/javascript'></script>
  </head>
  <body>
    <div id="counter">0</div>
  </body>
</html>

Incrementing values


$('#counter').increment();

Decrementing values


$('#counter').decrement();

Getting current value


$('#counter').counterValue();

Custom increment/decrement step

You can increment or decrement by any value you desire:


// Increment counter by 10
$('#counter').increment(10);

Listening to increment/decrement events


$('#counter').bind('increment', function(event, counter, value) {
  console.log('Incremented ' + counter + ' ' +  value);
});
$('#counter').bind('decrement', function(event, counter, value) {
  console.log('Decremented ' + counter + ' ' + value);
});