W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h2>JavaScript switch</h2> <p id="demo"></p> <script> var x = "0"; switch (x) { case 0: text = "Off"; break; case 1: text = "On"; break; default: text = "未找到值"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>