//获取星期 //例子1 var day=new Date().getDay(); switch (day) { case 6: x="Today it's Saturday"; break; case 0: x="Today it's Sunday"; break; default: x="Looking forward to the Weekend"; }
输出
"Looking forward to the Weekend"
//例子2 var day=new Date().getDay(); switch (day) { case 0: x="Today it's Sunday"; break; case 1: x="Today it's Monday"; break; case 2: x="Today it's Tuesday"; break; case 3: x="Today it's Wednesday"; break; case 4: x="Today it's Thursday"; break; case 5: x="Today it's Friday"; break; case 6: x="Today it's Saturday"; break; }
输出
"Today it's Wednesday"
//例子3 switch(t.update_state) { case 1: $('#h-progress-status .value').text("HdwUpdateRestarting") break; case 2: $('#h-progress-status .value').text("HdwUpdateRestartSuccess") break; case 3: $('#h-progress-status .value').text("HdwUpdateRestartFailure") break; case 11: $('#h-progress-status .value').text("HdwUpdateFlashWiping") break; case 12: $('#h-progress-status .value').text("HdwUpdateFlashWipeSuccess") break; case 13: $('#h-progress-status .value').text("HdwUpdateFlashWipeFailure") break; case 21: $('#h-progress-status .value').text("HdwUpdateFlashReprogramming") break; case 22: $('#h-progress-status .value').text("HdwUpdateFlashReprogramSuccess") break; case 23: $('#h-progress-status .value').text("HdwUpdateFlashReprogramFailure") break; case 31: $('#h-progress-status .value').text("HdwUpdateAppStarting") break; case 32: $('#h-progress-status .value').text("HdwUpdateAppStartSuccess") break; case 33: $('#h-progress-status .value').text("HdwUpdateAppStartFailure") break; default: console.log("something else!") }