Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Number.isInteger = Number.isInteger || function(value) {
- return typeof value === 'number' && Number.isFinite(value) && !(value % 1);
- };
- $(document).on('click','.plusminus-btn',function(e) {
- var $input = $(this).siblings('input');
- var val = +$input.val();
- if ($(this).hasClass('minus')) {
- if (val < 2) return false;
- val--;
- } else {
- val++;
- }
- $input.val(val);
- });
- $(document).on('blur','.plusminus-input',function(e) {
- var n = +$(this).val();
- if (!Number.isInteger(n) || n < 1) {
- $(this).val(1);
- n = 1;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement