Last active
February 15, 2019 15:53
-
-
Save AndresInSpace/df5f090800ed88f00444f043567648cc to your computer and use it in GitHub Desktop.
Qty Input Addition/Subtraction for IE10+ (w/ JQuery for delegation.. feel free to change to vanilla JS) https://codepen.io/AndresInSpace/pen/xMyeVO
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
var editQty = (function(){ | |
function editValue(e) { | |
var input = e.target.nextElementSibling || e.target.previousElementSibling; | |
input.value = counter(e.target.classList.contains('plus'),input.value); | |
} | |
function counter(add,x) { | |
return add ? ++x : (x > 1 ? --x : x); | |
} | |
return function() { | |
var group = jQuery('.qty-wrapper'); | |
group.on('click', '.qty-counter', editValue); | |
} | |
}()); | |
editQty(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment