源代码
<!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()) { default: text = "Looking forward to the Weekend"; break; case 6: text = "Today is Saturday"; break; case 0: text = "Today is Sunday"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>
运行结果