// Quantity buttons function qtySum(){ var arr = document.getElementsByName('qtyInput'); var tot=0; for(var i=0;i'); $(".qtyButtons input").before('
'); $(".qtyDec, .qtyInc").on("click", function() { var $button = $(this); var oldValue = $button.parent().find("input").val(); if ($button.hasClass('qtyInc')) { var newVal = parseFloat(oldValue) + 1; } else { // don't allow decrementing below zero if (oldValue > 0) { var newVal = parseFloat(oldValue) - 1; } else { newVal = 0; } } $button.parent().find("input").val(newVal); qtySum(); $(".qtyTotal").addClass("rotate-x"); }); function removeAnimation() { $(".qtyTotal").removeClass("rotate-x"); } const counter = document.querySelector(".qtyTotal"); counter.addEventListener("animationend", removeAnimation); });