Created
August 7, 2015 17:57
-
-
Save jessehintze/b9cbbdfc823fe29a75b6 to your computer and use it in GitHub Desktop.
Click to add or subtract to qty box
This file contains hidden or 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
//product page qty | |
$('.sp-plus').on('click', function(){ | |
var newVal = (parseInt($('.sp-input').val(),10) +1); | |
var oldVal = parseInt($('.sp-input').val(), 10); | |
if (isNaN(oldVal) === true){ | |
$('.sp-input').val(1); | |
} else { | |
$('.sp-input').val(newVal); | |
} | |
}); | |
$('.sp-minus').on('click', function(){ | |
var newVal = (parseInt($('.sp-input').val(),10) -1); | |
var oldVal = parseInt($('.sp-input').val(), 10); | |
if(oldVal <= 1) { | |
return false; | |
} else if (isNaN(oldVal) === true){ | |
$('.sp-input').val(1); | |
} else { | |
$('.sp-input').val(newVal); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment