Created
September 1, 2016 09:43
-
-
Save MOgorodnik/c73112fcbbb06329699a5ff552bfec65 to your computer and use it in GitHub Desktop.
number input plus minus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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