9.2demo.html 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // alert("你好")
  15. var month = prompt("请输入月份");
  16. console.log(month,'月份',332)
  17. switch(month) {
  18. case "1":
  19. case "3":
  20. case "5":
  21. case "7":
  22. case "8":
  23. case "10":
  24. case "12":
  25. alert("当前是"+month+"月,天数是31天");
  26. break;
  27. case "4":
  28. case "6":
  29. case "9":
  30. case "11":
  31. alert("当前是"+month+"月,天数是30天");
  32. break;
  33. case "2":
  34. alert("当前是"+month+"月,天数是28天");
  35. break;
  36. default:
  37. alert("输入月份不正确");
  38. break;
  39. }
  40. </script>
  41. </body>
  42. </html>