码迷,mamicode.com
首页 > 其他好文 > 详细

5.switch 语句

时间:2016-05-31 06:26:36      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>switch 语句</title>
<script type="text/javascript" >
    var hours = window.prompt("请输入一个0-24的时间点数字");
    hours = parseInt(hours);//把字符串类型转为整型
    switch( hours ) {
        case 12:
        case 13:
        case 14:
        case 15:
        case 16:
        case 17:
        case 18:
        document.write("<h3>下午好!欢迎来到贵美。</h3>");
        break;
        
        case 19:
        case 20:
        case 21:
        case 22:
        case 23:
        case 24:
        document.write("<h3>晚上好!欢迎来到贵美。</h3>");
        break;
        
        default:
        document.write("<h3>上午好!欢迎来到贵美。</h3>");
    
    
    }

</script>
</head>

<body>
</body>
</html>

 

5.switch 语句

标签:

原文地址:http://www.cnblogs.com/xiaotaoxu/p/5544551.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!