问答详情
源自:4-4 多种选择(Switch语句)

帮我看看问题出在哪,点按钮没反应。。

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>switch</title>

<script type="text/JavaScript">

function today(){

var day =prompt("今天星期几呀"," ");

switch (day)

{

 case 1:

 case 2:

 document.write("学习理念知识");

 break;

 case 3:

 case 4:

 document.write("到企业实践");

 break;

 case 5:

 document.write("总结经验");

 break;

 case 6;

 case 7;

 document.write("周六、日休息和娱乐");

 break;

 default;

}

}

</script>

</head>

<body>

    <input type="button" value="我是按钮" onclick="today()">

</body>

</html>



提问者:TeamLin 2018-07-13 23:47

个回答

  • qq_抛物线_0
    2018-07-14 11:53:58
    已采纳

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>switch</title>
    <script type="text/JavaScript">
    function today(){
    var day =prompt("今天星期几呀","");
    switch (parseInt(day))
    {
     case 1:
     case 2:
     document.write("学习理念知识");
     break;
     case 3:
     case 4:
     document.write("到企业实践");
     break;
     case 5:
     document.write("总结经验");
     break;
     case 6:
     case 7:
     document.write("周六、日休息和娱乐");
     break;
    default: document.write("输入错误!");
    }
    }
    </script>
    </head>
    <body>
    <input type="button" value="我是按钮" onclick="today()">
    </body>
    </html>

  • 慕虎2691697
    2018-07-18 09:55:53

    case 后面是: 有几个打成了;

  • TeamLin
    2018-07-13 23:58:21

    : 打成 ; 了...