<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>switch</title>
<script type="text/JavaScript">
function zhd(){
var myweek =prompt("请输入今天星期几","456");
switch(myweek)
{
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:
alert("输得不对啊");
}}
</script>
</head>
<body>
<input type="button" value="应该干什么" onClick="zhd()">
</body>
</html>
var myweek =prompt("请输入今天星期几","456");
这一行代码最后的)改成英文的)
default:
这里是冒号也错了,改成英文冒号吧
修改后的代码
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>switch</title> <script type="text/JavaScript"> function zhd(){ var myweek =prompt("请输入今天星期几","456"); switch(myweek) { 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: alert("输得不对啊"); }} </script> </head> <body> <input type="button" value="应该干什么" onClick="zhd()"> </body> </html>