Advertisement
salmancreation

/*Plus Minus Start*/ Js HTML

Nov 5th, 2015
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Plus Minus Start*/
  2.          $(".cart-plus-minus-button").append('<div class="dec qtybutton">-</div><div class="inc qtybutton">+</div>');
  3.           $(".qtybutton").on("click", function() {
  4.             var $button = $(this);
  5.             var oldValue = $button.parent().find("input").val();
  6.             if ($button.text() == "+") {
  7.               var newVal = parseFloat(oldValue) + 1;
  8.             } else {
  9.                // Don't allow decrementing below zero
  10.               if (oldValue > 0) {
  11.                 var newVal = parseFloat(oldValue) - 1;
  12.                 } else {
  13.                 newVal = 0;
  14.               }
  15.               }
  16.             $button.parent().find("input").val(newVal);
  17.           });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement