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
"hello"
Bootstrap 3.3.0 Snippet by
bruno93
3.3.0
jQuery
Preview
HTML
CSS
JS
View Full Screen
Forked from
Fork
Fork this
Parent
682
 
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"> <div class="col-xs-3 col-xs-offset-3"> <div class="input-group number-spinner"> <span class="input-group-btn data-dwn"> <button class="btn btn-default btn-info" data-dir="dwn"><span class="glyphicon glyphicon-minus"></span></button> </span> <input type="text" class="form-control text-center" value="50" min="50" max="300"> <span class="input-group-btn data-up"> <button class="btn btn-default btn-info" data-dir="up"><span class="glyphicon glyphicon-plus"></span></button> </span> </div> </div> </div> </div>
/* just for preview */ .container { padding-top: 40px; } @media ( max-width: 585px ) { .input-group span.input-group-btn,.input-group input,.input-group button{ display: block; width: 100%; border-radius: 0; margin: 0; } .input-group { position: relative; } .input-group span.data-up{ position: absolute; top: 0; } .input-group span.data-dwn{ position: absolute; bottom: 0; } .form-control.text-center { margin: 34px 0; } .input-group-btn:last-child>.btn, .input-group-btn:last-child>.btn-group{ margin-left:0; } }
$(function() { var action; $(".number-spinner button").mousedown(function () { btn = $(this); input = btn.closest('.number-spinner').find('input'); btn.closest('.number-spinner').find('button').prop("disabled", false); if (btn.attr('data-dir') == 'up') { action = setInterval(function(){ if ( input.attr('max') == undefined || parseInt(input.val()) < parseInt(input.attr('max')) ) { input.val(parseInt(input.val())+5); }else{ btn.prop("disabled", true); clearInterval(action); } }, 50); } else { action = setInterval(function(){ if ( input.attr('min') == undefined || parseInt(input.val()) > parseInt(input.attr('min')) ) { input.val(parseInt(input.val())-1); }else{ btn.prop("disabled", true); clearInterval(action); } }, 50); } }).mouseup(function(){ clearInterval(action); }); });
Related:
See More
Free Template
BLK• Design System
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76