<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>