为什么我这个ifelse实现不了啊?
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title></title>
<script type="javascript" >
function result(){
var text1=parseInt(document.getElementById('txt1').value);
var text2=parseInt(document.getElementById('txt2').value);
var select=document.getElementById('select').value;
var res='';
if(select == "+"){
res=text1+text2;
}else if(select == "-"){
res=text1-text2;
}else if(select == "*"){
res=text1*text2;
}else{
res=text1/text2;
}
document.getElementById('result').value=res;
}
</script>
</head>
<body>
<form>
计算器
<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" id="but" value="=" onclick="result()" />
<input type="text" id="result" />
</form>
</body>
</html>