17.demo.html 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. // 案例1:进入页面 输入月份 页面显示当前月份及月份的天数;
  11. // var month = prompt("请输入月份");
  12. // // console.log(month);
  13. // switch(month) {
  14. // case "1":
  15. // case "3":
  16. // case "5":
  17. // case "7":
  18. // case "8":
  19. // case "10":
  20. // case "12":
  21. // console.log(month + "月份有31天");
  22. // break;
  23. // case 2:
  24. // console.log(month + "月份有19天");
  25. // break;
  26. // case "4":
  27. // case "6":
  28. // case "9":
  29. // case "11":
  30. // console.log(month + "月份有30天");
  31. // break;
  32. // default:
  33. // console.log("请输入正确的月份");
  34. // break;
  35. // }
  36. // 案例2:进入页面 输入年份 页面显示当前年月及平年/闰年;
  37. var year = prompt("请输入年份");
  38. console.log(year);
  39. if(year % 400 == 0 || year % 4 == 0 && year % 100 != 0) {
  40. alert(year + "年是闰年");
  41. } else {
  42. alert(year + "年是平年");
  43. }
  44. // 案例三:进入页面 输入三角形的宽高 弹出三角形的面积 函数
  45. </script>
  46. </body>
  47. </html>