window.initPlusMinusBox = function () { /*---------------------------- Cart Plus Minus Button ------------------------------ */ var CartPlusMinus = $('.cart-plus-minus'); CartPlusMinus.prepend('
'); CartPlusMinus.append(' '); $(".qtybutton").on("click", function () { var newVal; var $button = $(this); var oldValue = $button.parent().find("input").val(); if ($button.text() === "+") { newVal = parseFloat(oldValue) + 1; } else { // Don't allow decrementing below zero if (oldValue > 0) { newVal = parseFloat(oldValue) - 1; } else { newVal = 1; } } $button.parent().find("input").val(newVal).request(); }); }; (function ($) { initPlusMinusBox(); })(jQuery);