Blogger Information
Blog 8
fans 0
comment 0
visits 4375
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
简单计算器
风轻云淡
Original
513 people have browsed it
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>计算器</title>
  6. </head>
  7. <body>
  8. <script>
  9. function fn(){
  10. var od1= document.getElementById('d1').value
  11. od1=parseFloat(od1)
  12. var od2= document.getElementById('d2').value
  13. od2=parseFloat(od2)
  14. var od3=document.getElementById('d3')
  15. var oysf=document.getElementById('ysf').value
  16. if(oysf=='+'){
  17. od3.value=od1+od2
  18. }else if(oysf=='-'){
  19. od3.value=od1-od2
  20. }else if(oysf=='*'){
  21. od3.value=od1*od2
  22. }else {
  23. od3.value=od1/od2
  24. }
  25. }
  26. </script>
  27. <input id="d1" type="text" value="">
  28. <select id="ysf">
  29. <option value="+">+</option>
  30. <option value="-">-</option>
  31. <option value="*">*</option>
  32. <option value="÷">/</option>
  33. </select>
  34. <input id="d2" type="text" value=""><span>=</span>
  35. <input type="text" id="d3" value="">
  36. <button onclick="fn()">点击计算</button>
  37. </body>
  38. </html>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:代码书写习惯可以改一改,js代码一般放入body标签的结束之前
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post