简单教程
提交运行
代码编辑器:
<p>点击按钮基于不同的工作日时间输出信息</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { var text; switch (new Date().getDay()) { case 1: case 2: case 3: default: text = "Looking forward to the Weekend"; break; case 4: case 5: text = "Soon it is Weekend"; break; case 0: case 6: text = "It is Weekend"; } document.getElementById("demo").innerHTML = text; } </script>
运行结果: