Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"購物_數量選擇"
Bootstrap 3.3.0 Snippet by
taironlife
3.3.0
Preview
HTML
CSS
JS
View Full Screen
Fork
Fork this
2.1K
 
0 Fav
Post to Facebook
Tweet this
<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="row"> <h2 class="text-center">購物_數量選擇</h2> <div class="col-md-6"> <h2 class="text-center">無限制大小</h2> <div class="input-group number-spinner"> <span class="input-group-btn"> <button class="btn btn-default" data-dir="dwn"><span class="glyphicon glyphicon-minus"></span></button> </span> <input type="text" class="form-control text-center" value="1"> <span class="input-group-btn"> <button class="btn btn-default" data-dir="up"><span class="glyphicon glyphicon-plus"></span></button> </span> </div> </div> <div class="col-md-6"> <h2 class="text-center">有限制大小</h2> <div class="input-group number-spinner" style="display: inline-block;width: auto;"> <span class="input-group-btn" style="float: left;width: auto;"> <button class="btn btn-default" data-dir="dwn" style="height: 34;"><span class="glyphicon glyphicon-minus"></span></button> </span> <input name="buy_num" id="buy_num" type="text" class="form-control text-center" value="1" style="width:4em;"> <span class="input-group-btn" style="display: inline-block;"> <button class="btn btn-default" data-dir="up" style="height: 34;"><span class="glyphicon glyphicon-plus"></span></button> </span> </div> </div> </div> </div>
.btn-default{ color: #444444; border-radius: 0; background-color: #E2E2E2; border-color: #8E8E8E; }
$(document).on('click', '.number-spinner button', function () { var btn = $(this), oldValue = btn.closest('.number-spinner').find('input').val().trim(), newVal = 0; if (btn.attr('data-dir') == 'up') { newVal = parseInt(oldValue) + 1; } else { if (oldValue > 1) { newVal = parseInt(oldValue) - 1; } else { newVal = 1; } } btn.closest('.number-spinner').find('input').val(newVal); });
Related:
See More
Free Template
Paper Kit
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76