代码中id="fruit"为什么不能换成别的 如id="txt3",(在document.getElement(id名).value中的id也改的情况下)
<!DOCTYPE html>
<html>
<head>
<title>计算器</title>
<script type="text/javascipt">
function count(){
var value1=document.getElementById("txt1").value;
var value2=document.getElementById("txt2").value;
var sign=document.getElementById("select").value;
switch(sign){
case "+":result=parseFloat(value1)+parseFloat(value2);
break;
case "-":result=parseFloat(value1)-parseFloat(value2);
break;
case "*":result=parseFloat(value1)*parseFloat(value2);
break;
case "/":result=parseFloat(value1)/parseFloat(value2);
}
document.getElementById("fruit").value=coun;
}
</script>
</head>
<body>
<input type="text" id="txt1"/>
<select id="select">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" id="txt2"/>
<input type="button" value="=" onclick="count()"/>
<input type="text" id="fruit"/>
</body>
</html>