为什么我这个程序输入加法的话就不能执行,而其他则可以
无法进行加法
2018-04-27
<!DOCTYPE html>
<html>
<head>
<title> 事件</title>
<script type="text/javascript">
function count(){
var txt1 = parseInt(document.getElementById("tex1").value);
var txt2 = parseInt(document.getElementById("tex2").value);
var s = document.getElementById("select").value;
switch(s)
{
case "+":result=(txt1)+(txt2);
break;
case "-": result=(txt1)-(txt2);
break;
case "*":result=(txt1)*(txt2);
break;
case "/": result=(txt1)/txt2);
break;
}
document.getElementById('fruit').value=result;
}
</script>
</head>
<body>
<input type="text" id="tex1" />
<select id="select">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" id="tex2" />
<input type="button" value=" = " onclick="count()" />
<input type="text" id="fruit" onclick="count()" />
</body>
</html>
举报