10.练习.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. <!--
  10. 需求:
  11. 进入页面,输入月份,判断是几月并弹出该月的实际天数
  12. -->
  13. <script>
  14. var month = prompt("请输入月份");
  15. console.log(month);
  16. switch(month) {
  17. case "1":
  18. case "3":
  19. case "5":
  20. case "7":
  21. case "8":
  22. case "10":
  23. case "12":
  24. alert("当前是" + month + "月,该月有31天");
  25. break;
  26. case "2":
  27. alert("当前是" + month + "月,该月有28天");
  28. break;
  29. case "4":
  30. case "6":
  31. case "9":
  32. case "11":
  33. alert("当前是" + month + "月,该月有30天");
  34. break;
  35. default:
  36. alert("当前输入有误 请重新输入");
  37. break;
  38. }
  39. </script>
  40. </body>
  41. </html>