qq_守卫我的孤傲_0
2015-10-13 13:56
<!DOCTYPE html> <html> <head> <title>事件</title> <script type="text/javascript"> function count(){ var num1=parseFloat(document.getElementById("txt1").value); var num2=parseFloat(document.getElementById("txt2").value); var f=document.getElementById("select").value; var result=" "; swith(f){ case "+": result=num1+num2; break; case "-": result=num1-num2; break; case "*": result=num1*num2; break; default: result=num1/num2; break; } document.getElementById("fruit").value=result; } </script> </head> <body> <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' value=' = ' onclick="count()"/> <input type='text' id='fruit' /> </body> </html>
switch(f){}//这个拼错了
switch写成了swith
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题