<!DOCTYPE html>
<html>
<head>
<title> 事件</title>
<script type="text/javascript">
function count(){
var x=document.getElementById("text1").value;
var y=document.getElementById("text2").value;
var z=document.getElementById("select").value;
var n;
switch(z){
case '+': n=parseInt(x)+parseInt(y);break;
case "-": n=parseInt(x)-parseInt(y);break;
case "*": n=parseInt(x)*parseInt(y);break;
case "/": n=parseInt(x)/parseInt(y);break;
default: break;
}
document.getElementById("text3").value=n;
}
</script>
</head>
<body>
num1
<input type='text' id='text1'/>
<select>
<option value='+'>+</option>
<option value='-'>-</option>
<option value='*'>*</option>
<option value='/'>/</option>
</select>
num2
<input type='text' id='text2'/>
<input type='button' value ='=' onclick="count()"/>
<input type='text' id ='text3'/>
</body>
</html>
var z=document.getElementById("select").value;
<select>
<option value='+'>+</option>
<option value='-'>-</option>
<option value='*'>*</option>
<option value='/'>/</option>
</select>
问题出在这人,你拿的'select'是id,而下面的select是标签,可以在下面的加个select 的id,如<select id="select">