$(document).on('pageshow','#temperatureContents',function(){
$(document).off('click','#convertbtnTemp').on('click','#convertbtnTemp',function(){
textFieldValue = $('#numberField').val();
});
});
if(selectFrom == "celcius" && selectTo == "kelvin"){
celToKel(selectFrom,selectTo,textFieldValue);
}
function celToKel(selectFrom,selectTo,textFieldValue){
var value = Number(textFieldValue).toFixed(1);
var result = (value + 273.15);
displayResult(selectFrom,selectTo,result);
}
function displayResult(selectFrom,selectTo,result){
$('#resultDiv').show();
$('#resultDisplay').empty().append("the Result of " + selectFrom + " to " + selectTo + " is: " + result);
}
問題是這兩條線也給我1 + 273.15 = 1.0273.15,但我想補充1 273.15怎樣才能得到呢?JavaScript給出錯誤的結果?
var value = Number(textFieldValue).toFixed(1);
var result = (value + 273.15);