I have this range slider built with BS and bootstrap-slider.js that is working nicely by dragging:
<div class="container range">
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-8">
<div id="ex6CurrentSliderValLabel">
<span id="ex6SliderVal">2.5</span>
</div>
<input id="ex6" type="text" data-slider-min="0" data-slider-max="4" data-slider-step="0.01" data-slider-value="2.5"/>
</div>
<div class="col-sm-2">
</div>
</div>
</div>
the JS:
$("#ex6").slider();
$("#ex6").on("slide", function(slideEvt) {
$("#ex6SliderVal").text(slideEvt.value);
});
Working fiddle: https://jsfiddle.net/kjuh62yg/
I would like to also add plus and minus arrows (buttons) to increment and decrement the value with mouse click.
You can simply use
getValueandsetValueof bootstrap slider toincrementand decrement value of yoursliderwithbuttonclick or+OR-sign in thedemoi created for you.In the
incrementyou will get the current-value and increase the value by setting the value and adding the value of your slider which is to0.01floatnumber. To make sure that we are adding thecorrectfloatvaluewe can use toFixed() function which ensures that we are adding floatdecimalnot straight exact numbers.In the
decrementwe use the same but in this case we subtract the value of thesliderand move the backwards for visual effect as well as we update the span textLive Demo: