W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <body> <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> </body> </html>