Skip to content

Instantly share code, notes, and snippets.

@AndresInSpace
Last active February 15, 2019 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndresInSpace/df5f090800ed88f00444f043567648cc to your computer and use it in GitHub Desktop.
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
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