<h2>JavaScript switch</h2> <p id="demo"></p> <script> var text; switch (new Date().getDay()) { default: text = "期待周末"; break; case 6: text = "今天是周六"; break; case 0: text = "今天是周日"; } document.getElementById("demo").innerHTML = text; </script>