JS案例:通过switch语句判断今天是星期几
来自CloudWiki
<!doctype html> <html> <head> <meta charset="utf-8"> <title>switch语句应用案例</title> </head><body><pre> <script type="text/javascript"> var date=new Date(); document.write("今天是:"); switch(date.getDay()){ case 1: document.write("星期一"); break; case 2: document.write("星期二"); break; case 3: document.write("星期三"); break; case 4: document.write("星期四"); break; case 5: document.write("星期五"); break; case 6: document.write("星期六"); break; default: document.write("星期日"); } </script> </pre></body></html>