1 回答
TA贡献19条经验 获得超9个赞
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 = parseFloat(oTxt1) + parseFloat(oTxt2);
break;
case "-":
result = parseFloat(oTxt1) - parseFloat(oTxt2);
break;
case "*":
result = parseFloat(oTxt1) * parseFloat(oTxt2);
break;
default:
result = parseFloat(oTxt1) / parseFloat(oTxt2);
}
document.getElementById("fruit").value = result;
}
JS完成的简单计算器,请采纳!
添加回答
举报