码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript.switch (true)

时间:2015-10-24 23:11:39      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
<head>
    <title>Switch Statement Example 4</title>
    <script type="text/javascript">
        var num = 25;
        switch (true) {
            case num < 0: 
                alert("Less than 0.");
                break;
            case num >= 0 && num <= 10: 
                alert("Between 0 and 10.");
                break;
            case num > 10 && num <= 20: 
                alert("Between 10 and 20.");
                break;
            default: 
                alert("More than 20.");
        }

    </script>
</head>
<body>

</body>
</html>

技术分享

JavaScript.switch (true)

标签:

原文地址:http://www.cnblogs.com/fatoland/p/4907742.html

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