Skip to content

Instantly share code, notes, and snippets.

@littlekbt
Last active July 29, 2016 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save littlekbt/1d52ce2953e981a443b58f845804aace to your computer and use it in GitHub Desktop.
Save littlekbt/1d52ce2953e981a443b58f845804aace to your computer and use it in GitHub Desktop.
(function( $ ){
$.fn.incr = function() {
return this.html(parseInt(this.html()) + 1);
};
$.fn.decr = function() {
return this.html(parseInt(this.html()) - 1);
};
})( jQuery );
$(function() {
// init
var n = $('#num');
n.html(0);
$('#incr').on('click', function() {
n.incr();
});
$('#decr').on('click', function() {
n.decr();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment