"minus-input-plus"
Bootstrap 3.3.0 Snippet by makbash

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="count-input space-bottom"> <a class="incr-btn" data-action="decrease" href="#">–</a> <input class="quantity" type="text" name="quantity" value="1"/> <a class="incr-btn" data-action="increase" href="#">&plus;</a> </div> </div>
.count-input { position: relative; width: 100%; max-width: 165px; margin: 10px 0; } .count-input input { width: 100%; height: 36.92307692px; border: 1px solid #000; border-radius: 2px; background: none; text-align: center; } .count-input input:focus { outline: none; } .count-input .incr-btn { display: block; position: absolute; width: 30px; height: 30px; font-size: 26px; font-weight: 300; text-align: center; line-height: 30px; top: 50%; right: 0; margin-top: -15px; text-decoration:none; } .count-input .incr-btn:first-child { right: auto; left: 0; top: 46%; } .count-input.count-input-sm { max-width: 125px; } .count-input.count-input-sm input { height: 36px; } .count-input.count-input-lg { max-width: 200px; } .count-input.count-input-lg input { height: 70px; border-radius: 3px; }
$(".incr-btn").on("click", function (e) { var $button = $(this); var oldValue = $button.parent().find('.quantity').val(); $button.parent().find('.incr-btn[data-action="decrease"]').removeClass('inactive'); if ($button.data('action') == "increase") { var newVal = parseFloat(oldValue) + 1; } else { // Don't allow decrementing below 1 if (oldValue > 1) { var newVal = parseFloat(oldValue) - 1; } else { newVal = 1; $button.addClass('inactive'); } } $button.parent().find('.quantity').val(newVal); e.preventDefault(); });

Related: See More


Questions / Comments: