1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
-
- // 案例1:进入页面 输入月份 页面显示当前月份及月份的天数;
- // var month = prompt("请输入月份");
- // // console.log(month);
- // switch(month) {
- // case "1":
- // case "3":
- // case "5":
- // case "7":
- // case "8":
- // case "10":
- // case "12":
- // console.log(month + "月份有31天");
- // break;
- // case 2:
- // console.log(month + "月份有19天");
- // break;
- // case "4":
- // case "6":
- // case "9":
- // case "11":
- // console.log(month + "月份有30天");
- // break;
- // default:
- // console.log("请输入正确的月份");
- // break;
- // }
- // 案例2:进入页面 输入年份 页面显示当前年月及平年/闰年;
- var year = prompt("请输入年份");
- console.log(year);
- if(year % 400 == 0 || year % 4 == 0 && year % 100 != 0) {
- alert(year + "年是闰年");
- } else {
- alert(year + "年是平年");
- }
- // 案例三:进入页面 输入三角形的宽高 弹出三角形的面积 函数
- </script>
-
- </body>
- </html>
|