我正在尝试使用toFixed()函数将数字的屏幕输出转换为两位小数。我只是不确定如何实现这一目标。我有以下功能:
jQuery( document ).ready(function( $ ) {
$( "#slider-deposit" ).slider({
value: 100,
min: <?php echo json_encode($minDeposit); ?>,
max: <?php echo json_encode($maxDeposit); ?>,
step: 1,
slide: function( event, ui ) {
$( "#amount-deposit" ).val( "" + ui.value );
totalPayableFunc();
monthlyPaymentsFunc();
}
});
$( "#amount-deposit" ).val( "" + $( "#slider-deposit" ).slider( "value" ) );
});
目前显示的数字有一个小数位,我需要显示两位小数。
由于
答案 0 :(得分:1)
试试这个:
jQuery( document ).ready(function( $ ) {
$( "#slider-deposit" ).slider({
value: 100,
min: <?php echo json_encode($minDeposit); ?>,
max: <?php echo json_encode($maxDeposit); ?>,
step: 1,
slide: function( event, ui ) {
$( "#amount-deposit" ).val(Number(ui.value).toFixed(2));
totalPayableFunc();
monthlyPaymentsFunc();
}
});
$( "#amount-deposit" ).val( "" + $( "#slider-deposit" ).slider( "value" ) );
});