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