为了账号安全,请及时绑定邮箱和手机立即绑定

求教 哪里出错了

求教 哪里出错了

慕粉4062053 2016-12-03 21:36:00
<!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=gb2312" /> <title> 计算器</title> <script type="text/javascript"> function ys(){ var y=document.getElementById("yi").value; var e=document.getElementById("er").value; var ee=document.getElementById("dd").value; var s=""; switch(ee) { case "加":  s=parseInt(y)+parseInt(e);  break;  case"减":  s=parseInt(y)-parseInt(e);  break; case"乘": s=parseInt(y)*parseInt(e); break; default: s=parseInt(y)/parseInt(e); } document.getElementById("san").value=s; } </script> </head> <body> <input id="yi" type="text" />     <select id="dd">       <option value="加">+</option>       <option value="减">-</option>       <option value="乘">*</option>       <option value="除">/</option>     </select> <input id="er" type="text" /> <input value="=" type="button" onclick="ys()" /> <input id="san" type="text" /> </body> </html>
查看完整描述

6 回答

?
慕UI8820655

TA贡献15条经验 获得超4个赞

把Script代码写在body里,或者在你的Script中写入window.onload=function(){

}

查看完整回答
1 反对 回复 2016-12-05
?
lllqw

TA贡献6条经验 获得超4个赞

27行最后那个右括号要换成英文的右括号

查看完整回答
1 反对 回复 2016-12-03
  • 6 回答
  • 0 关注
  • 1576 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信