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 6: text = "Today is Saturday"; break; case 0: text = "Today is Sunday"; break; default: text = "Looking forward to the Weekend"; } document.getElementById("demo").innerHTML = text; } </script> </body> </html>