项目描述
上传时间
浏览人数
用法及示例:
<body> <script> var week = new Date().getDay(); console.log(week); </script> </body> <script> var day = new Date().getDay(); switch (day) { case 0: x = "Today it's Sunday"; console.log(x); break; case 1: x = "Today it's Monday"; console.log(x); break; case 2: x = "Today it's Tuesday"; console.log(x); break; case 3: x = "Today it's Wednesday"; console.log(x); break; case 4: x = "Today it's Thursday"; console.log(x); break; case 5: x = "Today it's Friday"; console.log(x); break; case 6: x = "Today it's Saturday"; console.log(x); break; } document.write("今天是星期" + x); </script>
<body> <!--<script>--> <!--var week = new Date().getDay();--> <!--console.log(week);--> <!--</script>--> <p>点击下面的按钮,只要 i 小于 5 就一直循环代码块。</p> <button onclick="myFunction()">点击这里</button> <p id="demo"></p> </body> <script> // var day = new Date().getDay(); // switch (day) { // case 0: // x = "Today it's Sunday"; // console.log(x); // break; // case 1: // x = "Today it's Monday"; // console.log(x); // break; // case 2: // x = "Today it's Tuesday"; // console.log(x); // break; // case 3: // x = "Today it's Wednesday"; // console.log(x); // break; // case 4: // x = "Today it's Thursday"; // console.log(x); // break; // case 5: // x = "Today it's Friday"; // console.log(x); // break; // case 6: // x = "Today it's Saturday"; // console.log(x); // break; // } // document.write("今天是星期" + x); function myFunction() { var x = "", i = 0; do { x = x + "The number is " + i + "<br>"; console.log(x); i++; } while (i < 5); document.getElementById("demo").innerHTML = x; } </script>