我正在使用来自http://www.eyecon.ro/bootstrap-slider/
的Bootstrap Slider它工作得很好,但是给我的十进制值是正确的,但是当它滑动时,它从2.00变为.2.0000000000001,然后下一个值是2.01,依此类推。
如何将小数值限制为.00(即仅2个位置)?
<input type="text" class="sliderMaster slider-horizontal" id="weight" name="weight" data-slider-min="0.24" data-slider-max="16.38" data-slider-step="0.01" data-slider-value="[0.24,16.38]" value="0.24,16.38" data-slider-orientation="horizontal" data-slider-selection="after" data-slider-tooltip="show" data-slider-handle="square">
$(function(){
$('#weight').slider({
formater: function(value) {
return ''+value;
}
}).on('slideStop', function(ev){
$(this).val($(this).data('slider').getValue());
});
$("#getVal").click(function() {
console.log("Value 2 = "+$("#weight").data('slider').getValue());
});
});