switch中case 6 的case "6"
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>switch</title> <script?type="text/JavaScript"> function?jump(){ ????var?myweek?=?prompt("今天星期幾?"); switch?(myweek) { ?case?"1": ?case?"2": ?document.write("學(xué)習(xí)理念知識(shí)"); ?break; ?case?"3": ?case?"4": ?document.write("到企業(yè)實(shí)踐"); ?break; ?case?"5": ?document.write("總結(jié)經(jīng)驗(yàn)"); ?break; ?case?6: ?case?7: ?document.write("周六、日休息和娛樂(lè)"); ?break; ?default: ?alert("該干嘛干嘛去"); } } </script> </head> <body> <input?type="button"?onclick="jump()"?value="點(diǎn)點(diǎn)看"> </body> </html>
迷了
switch中case 6 的case "6"
那個(gè)算數(shù)字和字符串
prompt 彈出的輸入 6 異常顯示default
輸入加引號(hào)的3 就正常
2015-07-31
prompt 輸出的內(nèi)容為string類(lèi)型, 6為number類(lèi)型,'6'為string類(lèi)型,所以需要用case '6'