為什么按“=”結果不顯示出來呢
?function count(){
??? var oTxt1 = document.getElementById("txt1").value;
??? var oTxt2 = document.getElementById("txt2").value;
??? var oSlt = document.getElementById("select").value;
??? var result = " ";
??? switch(oSlt) {
??????? case "+":
??????????? result = parseInt(oTxt1) +parseInt(oTxt2);
??????????? break;
??????? case "-":
??????????? result = parseInt(oTxt1) - parseInt(oTxt2);
??????????? break;
??????? case "*":
??????????? result = parseInt(oTxt1) * parseInt(oTxt2);
??????????? break;
??????? default:
??????????? result =parseInt(oTxt1) / parseInt(oTxt2);
??? }
??? document.getElementById("fruit").value =? result;
?? ?
?? }
2019-08-05
因為你要在按鍵那寫個onclick調用函數? <input type='button' value=' = ' onclick="count()" />