Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:代码书写习惯可以改一改,js代码一般放入body标签的结束之前
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>计算器</title>
</head>
<body>
<script>
function fn(){
var od1= document.getElementById('d1').value
od1=parseFloat(od1)
var od2= document.getElementById('d2').value
od2=parseFloat(od2)
var od3=document.getElementById('d3')
var oysf=document.getElementById('ysf').value
if(oysf=='+'){
od3.value=od1+od2
}else if(oysf=='-'){
od3.value=od1-od2
}else if(oysf=='*'){
od3.value=od1*od2
}else {
od3.value=od1/od2
}
}
</script>
<input id="d1" type="text" value="">
<select id="ysf">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="÷">/</option>
</select>
<input id="d2" type="text" value=""><span>=</span>
<input type="text" id="d3" value="">
<button onclick="fn()">点击计算</button>
</body>
</html>