源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <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>
运行结果