源代码:
下载代码
AI 编程工具
点击运行
<html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <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>
运行结果: