12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <!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 + "年是平年");
- // }
- // 案例三:进入页面 输入三角形的宽高 弹出三角形的面积 函数
- function fn1() {
- var width = prompt("请输入宽度");
- var height = prompt("请输入高度");
- var area = (width * height) / 2;
- alert(area);
- }
- fn1();
- </script>
-
- </body>
- </html>
|