<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript">function count(){ var num1=document.getElementById("num1").value , symble=document.getElementById("symble"), num2=document.getElementById("num2").value , result; switch(symble){ case"+": result=parseInt(num1)+parseInt(num2); break; case"-": result=parseInt(num1)-parseInt(num2); break; case"*": result=parseInt(num1)*parseInt(num2); break; case"/": result=parseInt(num1)/parseInt(num2); break; default: result=null; } document.getElementById("num3") = result; }</script>><title>计算器简单功能实现</title></head><body><input type="text" name="num" id="num1"><select id="symble"><option>+</option><option>-</option><option selected="selected">*</option><option>/</option></select><input type="text" name="num" id="num2"><input type="button" value="=" onclick = "count()"><input type="text" name="num" id="num3"></body></html>
1 回答
已采纳
Caballarii
TA贡献1123条经验 获得超629个赞
symble=document.getElementById("symble").value,
document.getElementById("num3").value= result;
两个地方
添加回答
举报
0/150
提交
取消