function calculate()
{
var num1 = document.getElementById("input1").value;
var num2 = document.getElementById("input2").value;
var operator = document.getElementById("operation");
var totalNum = document.getElementById("total");
if (operator == "+")
{
parseDouble(totalNum = num1 + num2);
}
else if(operator == "-")
{
parseDouble(totalNum = num1 - num2);
}
total.value = totalNum;
}
我的輸出是[對象HTMLInputElement]。 如何區分數學運算?如何在數學運算符中輸入用戶密鑰
嘗試'開關(){情況..}' – hjpotter92
另外,我想你想'的document.getElementById( 「操作」)。value'有 – hjpotter92
嘗試'operator.value'(或^) –