xxxxxxxxxx
<html>
<head>
<meta charset="utf-8">
<title>编程狮(w3cschool.cn)</title>
</head>
<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>