RuthlessPotato丶
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完成的简单计算器,请采纳!