Skip to content

Instantly share code, notes, and snippets.

@KANekT
Last active August 29, 2015 14:07
Show Gist options
  • Save KANekT/1a4cec0a2e2b3e3e608b to your computer and use it in GitHub Desktop.
Save KANekT/1a4cec0a2e2b3e3e608b to your computer and use it in GitHub Desktop.
BootStrap Spinner
<div class="input-group spinner">
<input type="text" class="form-control" value="@Model">
<div class="input-group-btn-vertical">
<span class="btn btn-default"><i class="glyphicon glyphicon-chevron-up"></i></span>
<span class="btn btn-default"><i class="glyphicon glyphicon-chevron-down"></i></span>
</div>
</div>
(function($) {
$('.spinner .btn:first-of-type').on('click', function() {
$('.spinner input').val(parseInt($('.spinner input').val(), 10) + 1);
});
$('.spinner .btn:last-of-type').on('click', function() {
$('.spinner input').val(parseInt($('.spinner input').val(), 10) - 1);
});
})(jQuery);
.spinner {
width: 100px;
}
.spinner input {
text-align: right;
}
.input-group-btn-vertical {
position: relative;
white-space: nowrap;
width: 18px;
vertical-align: middle;
display: table-cell;
}
.input-group-btn-vertical > .btn {
display: block;
float: none;
width: 100%;
max-width: 100%;
padding: 8px;
margin-left: -1px;
position: relative;
border-radius: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.input-group-btn-vertical > .btn:first-child {
border-top-right-radius: 4px;
}
.input-group-btn-vertical > .btn:last-child {
margin-top: -2px;
border-bottom-right-radius: 4px;
}
.input-group-btn-vertical i{
font-size: 10px;
left: 3px;
position: absolute;
top: 2px;
}
.input-group-btn-vertical > .btn:last-child i{
left: 2px;
top: 3px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment