Skip to content

Instantly share code, notes, and snippets.

@MOgorodnik
Created September 1, 2016 09:43
Show Gist options
  • Save MOgorodnik/c73112fcbbb06329699a5ff552bfec65 to your computer and use it in GitHub Desktop.
Save MOgorodnik/c73112fcbbb06329699a5ff552bfec65 to your computer and use it in GitHub Desktop.
number input plus minus
// number input plus minus
// http://pcvector.net/scripts/forms/380-uvelichit-i-umenshit-znachenie-v-pole-input.html
$('.js-minus').click(function () {
var $input = $(this).parent().parent().find('input');
// var $input = $(this).parents(".number").find('input');
var count = parseInt($input.val()) - 1;
count = count < 1 ? 1 : count;
$input.val(count);
$input.change();
return false;
});
$('.js-plus').click(function () {
var $input = $(this).parent().parent().find('input');
// var $input = $(this).parents(".number").find('input');
$input.val(parseInt($input.val()) + 1);
$input.change();
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment