Discover the intuitive number spinner from 一号娱乐APP, designed for Bootstrap 3. Enjoy smooth interaction with mouse wheel and keyboard controls.
<input id="demo0"
type="text"
value="55"
name="demo0"
data-bts-min="0"
data-bts-max="100"
data-bts-init-val=""
data-bts-step="1"
data-bts-decimal="0"
data-bts-step-interval="100"
data-bts-force-step-divisibility="round"
data-bts-step-interval-delay="500"
data-bts-prefix=""
data-bts-postfix=""
data-bts-prefix-extra-class=""
data-bts-postfix-extra-class=""
data-bts-booster="true"
data-bts-boostat="10"
data-bts-max-boosted-step="false"
data-bts-mousewheel="true"
data-bts-button-down-class="btn btn-default"
data-bts-button-up-class="btn btn-default"
/>
<script>
$("input[name='demo0']").TouchSpin({
});
</script>
<input id="demo_vertical" type="text" value="" name="demo_vertical">
<script>
$("input[name='demo_vertical']").TouchSpin({
verticalbuttons: true
});
</script>
<input id="demo_vertical2" type="text" value="" name="demo_vertical2">
<script>
$("input[name='demo_vertical2']").TouchSpin({
verticalbuttons: true,
verticalupclass: 'glyphicon glyphicon-plus',
verticaldownclass: 'glyphicon glyphicon-minus'
});
</script>
<input id="demo1" type="text" value="55" name="demo1">
<script>
$("input[name='demo1']").TouchSpin({
min: 0,
max: 100,
step: 0.1,
decimals: 2,
boostat: 5,
maxboostedstep: 10,
postfix: '%'
});
</script>
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="demo2" class="col-md-5 control-label">Example:</label> <input id="demo2" type="text" value="0" name="demo2" class="col-md-7 form-control">
</div>
</form>
<script>
$("input[name='demo2']").TouchSpin({
min: -1000000000,
max: 1000000000,
stepinterval: 50,
maxboostedstep: 10000000,
prefix: '$'
});
</script>
<input id="demo3" type="text" value="" name="demo3">
<script>
$("input[name='demo3']").TouchSpin();
</script>
The `initval` setting is applied only when the input field lacks a `value` attribute.
<input id="demo3_21" type="text" value="" name="demo3_21">
<script>
$("input[name='demo3_21']").TouchSpin({
initval: 40
});
</script>
<input id="demo3_22" type="text" value="33" name="demo3_22">
<script>
$("input[name='demo3_22']").TouchSpin({
initval: 40
});
</script>
Adjust the overall size of the control by adding `input-sm` or `input-lg` classes to the input field, or by placing the plugin within an `input-group` that has `input-group-sm` or `input-group-lg` classes.
<input id="demo4" type="text" value="" name="demo4" class="input-sm">
<script>
$("input[name='demo4']").TouchSpin({
postfix: "a button",
postfix_extraclass: "btn btn-default"
});
</script>
<div class="input-group input-group-lg">
<input id="demo4_2" type="text" value="" name="demo4_2" class="form-control input-lg">
</div>
<script>
$("input[name='demo4_2']").TouchSpin({
postfix: "a button",
postfix_extraclass: "btn btn-default"
});
</script>
<div class="input-group">
<input id="demo5" type="text" class="form-control" name="demo5" value="50">
<div class="input-group-btn">
<button type="button" class="btn btn-default">Action</button>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu pull-right" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
</div>
<script>
$("input[name='demo5']").TouchSpin({
prefix: "pre",
postfix: "post"
});
</script>
$("input[name='demo6']").TouchSpin({
buttondown_class: "btn btn-link",
buttonup_class: "btn btn-link"
});
$("input[name='demo7']").TouchSpin({
replacementval: 10
});
| Options | Default Value | Description |
|---|---|---|
initval | "" | The `initval` is used when the input field has no `value` attribute. An empty string means the initial value is blank. |
replacementval | "" | Applied when the user leaves the field empty or enters non-numeric characters. An empty string means the value remains unchanged. |
min | 0 | Minimum value. |
max | 100 | Maximum value. |
step | 1 | Increment/decrement step value. |
forcestepdivisibility | 'round' | How to force the value to be divisible by step value: 'none' | 'round' | 'floor' | 'ceil' |
decimals | 0 | Number of decimal places. |
stepinterval | 100 | Refresh rate in milliseconds. |
stepintervaldelay | 500 | Delay before auto-scrolling starts (milliseconds). |
verticalbuttons | false | Enable traditional up/down buttons. |
verticalupclass | 'glyphicon glyphicon-chevron-up' | Class for the up button in vertical mode. |
verticaldownclass | 'glyphicon glyphicon-chevron-down' | Class for the down button in vertical mode. |
prefix | "" | Prefix text for the input. |
postfix | "" | Suffix text for the input. |
prefix_extraclass | "" | Additional class for the prefix. |
postfix_extraclass | "" | Additional class for the suffix. |
booster | true | Enable continuous acceleration when holding down buttons. |
boostat | 10 | Step value during acceleration. |
maxboostedstep | false | Maximum step value during acceleration. |
mousewheel | true | Enable mouse wheel value changes. |
buttondown_class | 'btn btn-default' | Class for the down button. |
buttonup_class | 'btn btn-default' | Class for the up button. |
buttondown_txt | '-' | Content for the down button. |
buttonup_txt | '+' | Content for the up button. |
The plugin emits the following events on the original input field, which you can listen to.
| Event | Description |
|---|---|
change | Triggered when the value changes via buttons (not triggered if `min` or `max` limits are reached). |
touchspin.on.startspin | Triggered when auto-scrolling starts in either direction. |
touchspin.on.startupspin | Triggered when auto-scrolling starts upwards. |
touchspin.on.startdownspin | Triggered when auto-scrolling starts downwards. |
touchspin.on.stopspin | Triggered when auto-scrolling stops. |
touchspin.on.stopupspin | Triggered when auto-scrolling stops upwards. |
touchspin.on.stopdownspin | Triggered when auto-scrolling stops downwards. |
touchspin.on.min | Triggered when the `min` limit is reached. |
touchspin.on.max | Triggered when the `max` limit is reached. |
You can directly trigger these events on the original input field.
Usage example: $("input").trigger("touchspin.uponce"); $("input").trigger("touchspin.updatesettings", {max: 1000});
| Event | Description |
|---|---|
touchspin.updatesettings | `updatesettings`: Update any setting on an initialized instance. |
touchspin.uponce | Increase value by one step. |
touchspin.downonce | Decrease value by one step. |
touchspin.startupspin | Start auto-scrolling upwards. |
touchspin.startdownspin | Start auto-scrolling downwards. |
touchspin.stopspin | Stop auto-scrolling. |
Explore More Features