W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h2>JavaScript switch</h2> <p id="demo"></p> <script> var text; switch (new Date().getDay()) { case 6: text = "今天是周六"; break; case 0: text = "今天是周日"; break; default: text = "期待周末"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>