美文网首页
if/switch练习

if/switch练习

作者: isMyNickName | 来源:发表于2018-11-04 18:58 被阅读0次
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>if练习1</title>
            <script type="text/javascript">
                /*
                 *  从键盘输入小明的期末成绩:
                 *  当成绩为100时,'奖励一辆BMW'
                 *  当成绩为[80-99]时,'奖励一台iphone15s'
                 *  当成绩为[60-80]时,'奖励一本参考书'
                 *  其他时,什么奖励也没有
                 */
                var score = prompt('请输入小明的期末成绩(0-100):');
                    if(score == 100){
                        alert('BMW');
                    }else if(score >= 80 && score <=99){
                        alert('iphone15s');
                    }else if(score >= 60 && score < 80){
                        alert('参考书');
                    }else{
                        alert('啥也没有');
                    }
            </script>
        </head>
        <body>
    
        </body>
    </html>
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>if练习2</title>
            <script type="text/javascript">
                /*
                *   大家都知道,男大当婚,女大当嫁。那么女方家长要嫁女儿,当然要提出一定的条件:
                *   高:180cm以上; 富:1000万以上; 帅:500以上;
                *   如果这三个条件同时满足,则:'我一定要嫁给他'
                *   如果三个条件有为真的情况,则:'嫁吧,比上不足,比下有余。'
                *   如果三个条件都不满足,则:'不嫁!'
                */
                var H = 180, M = 10000000, F = 500;
                    if(H >= 180 && M >= 10000000 && F >= 500){
                        alert('我一定要嫁给他');
                    }else if(H >= 180 || M >= 10000000 || F >= 500){
                        alert('嫁吧,比上不足,比下有余');
                    }else{
                        alert('不嫁');
                    }
            </script>
        </head>
        <body>
    
        </body>
    </html>
    <!DOCTYPE html>
    <html lang="en" xmlns="http://www.w3.org/1999/html">
    <head>
        <meta charset="UTF-8">
        <title>趣呵茶_茶叶_茶具_保健茶_和茶网-铁观音-普洱茶-原产地%20好品牌-网上购茶首选</title>
        <link rel="stylesheet" type="text/css" href="css/main.css">
    </head>
    <body>
        <div class="header">
            <img src="images/toppic.png">
        </div>
        <div class="header1">
            <div class="href1">
                <div class="f1">
                    <a href="register.html" target="_blank">免费注册</a>
                    <a href="login.html" target="_blank">登陆</a>
                </div>
                <div class="fr">
                    <a href="#" target="_blank">
                        <i class="order"><img src="images/order.png" /></i> 我的订单
                    </a>
                    <i class="wx"><img src="images/wx.png" /></i> <span>服务热线:400-8899-379</span>
                </div>
            </div>
        </div>
        <div class="header2">
            <div class="href1">
                <div class="logo"><a href="index.html" target="_blank"><img src="images/logo.png" /></a></div>
                <div class="f1 brand"><img src="images/brand.gif" /></div>
                <div class="f1 search">
                    <input type="text" id="textSearch" value=""><i><img src="images/search.png"></i>
                </div>
                <div class="fr shopping"><a href="cart.html">购物车</a></div>
            </div>
        </div>
        <div class="menu">
            <div class="menu1"><a href="#"><span>全部分类</span></a></div>
            <div class="menu2">
                <ul type="none">
                    <li><a href="#"><span>智能茶饮机</span></a></li>
                    <li><a href="#"><span>茶饮机专用茶</span></a></li>
                    <li><a href="#"><span>自饮茶</span></a></li>
                    <li><a href="#"><span>礼品茶</span></a></li>
                    <li><a href="#"><span>招商</span></a></li>
                    <li><a href="#"><span>社区</span></a></li>
                    <li><a href="#"><span>服务热线:400-8899-379</span></a></li>
                </ul>
            </div>
        </div>
    
        <!--轮播图-->
        <div class="lunbo">
            <a href="#"><img src="images/lb01.jpg"></a>
        </div>
        <div class="teaserver">
            <a href="#"><img src="images/pic1.png" /></a>
            <a href="#"><img src="images/pic1.png" /></a>
            <a href="#"><img src="images/pic1.png" /></a>
            <a href="#"><img src="images/pic1.png" /></a>
        </div>
        <div class="rline">
            <div class="b1">
                <span>&bull; 爆款特卖</span>
            </div>
            <div class="b2">
                <a href="#">点击查看更多&raquo;</a>
            </div>
        </div>
        <div class="temai">
            <div class="temai1">
                <a href="#"><img src="images/1-6051.png" /></a>
            </div>
            <div class="temai1">
                <a href="#"><img src="images/1-6051.png" /></a>
            </div>
            <div class="temai1">
                <a href="#"><img src="images/1-6051.png" /></a>
            </div>
            <div class="temai1">
                <a href="#"><img src="images/1-6051.png" /></a>
            </div>
            <div class="temai2">
                <a href="#"><img src="images/1-6051.png" /></a>
            </div>
        </div>
        <div class="gline">
            <div class="b1">
                <span>&bull; 品质好茶</span>
            </div>
        </div>
        <div class="gline">
            <div class="b2">
                <span>绿茶</span>
            </div>
            <div class="b3">
                <a href="#">点击查看更多&raquo;</a>
            </div>
        </div>
        <div class="lc">
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
        </div>
        <div class="gline">
            <div class="b2">
                <span>乌龙茶</span>
            </div>
            <div class="b3">
                <a href="#">点击查看更多&raquo;</a>
            </div>
        </div>
            <div class="lc">
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
            <div class="lc1">
                <a href="#"><img src="images/1-6597-78.png">
                <p>一级 &bull; 碧螺春70g</p>
                <p><span class="price-prev">¥45</span><span class="price-next">¥138.00</span></p></a>
            </div>
        </div>
            <div class="bot">
                <div class="f1">
                    <img src="images/f1.png">
                </div>
                <div class="f2">
                   <img src="images/f2.png">
                </div>
                <div class="f3">
                    <img src="images/f3.png">
                </div>
                <div class="f4">
                    <img src="images/f4.png">
                </div>
                <div class="bot-text">
                    <ul>
                        <li>
                            <p>100%原产地茶</p>
                            <p><a href="#">公用机型</a></p>
                            <p><a href="#">现调机型</a></p>
                            <p><a href="#">自助售卖机</a></p>
                        </li>
                        <li>
                            <p>新手上路</p>
                            <p><a href="#">如何付款</a></p>
                            <p><a href="#">配送说明</a></p>
                        </li>
                        <li>
                            <p>支付方式</p>
                            <p><a href="#">支付方式</a></p>
                            <p><a href="#">在线支付介绍</a></p>
                            <p><a href="#">汇款单招领</a></p>
                        </li>
                        <li>
                            <p>服务支持</p>
                            <p><a href="#">售后服务</a></p>
                            <p><a href="#">常见问题</a></p>
                            <p><a href="#">发票说明</a></p>
                        </li>
                        <li>
                            <p>关于和茶</p>
                            <p><a href="#">公司简介</a></p>
                            <p><a href="#">文化理念</a></p>
                            <p><a href="#">联系我们</a></p>
                        </li>
                        <li>
                            <p>服务热线:</p>
                            <p><a href="#">400-8899-379</a></p>
                            <p>周一至周日 9:00-21:00</p>
                            <p>(仅收市话费)</p>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="foot">
                <div class="ff">
                    <p>Copyright 2009-2017 hecha.cn All Rights Reserved.闽10202223-1号 营业执照 经营证照</p>
                    <p>福建和茶网络科技有限公司 版权所有 并保留所有权利禁止非法复制</p>
                </div>
                <div class="ff1">
                    <img src="images/f7.png">
                </div>
                <div class="ff2">
                    <img src="images/f5.png"><img src="images/f6.png">
                </div>
            </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title>switch练习1</title>
            <script type="text/javascript">
                /*
                 * 对于成绩大于等于60分的,输出'合格'。低于60分的,输出'不合格'
                 */
                var score = parseInt(prompt('请输入成绩'));
                    switch (true) {
                        case score>=60:
                            alert('合格');
                            break;
                        default:
                            alert('不合格');
                            break;
                    }
            </script>
        <body>
        </body>
    </html>
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title>switch练习2</title>
            <script type="text/javascript">
                /*
                 * 从键盘接收整数参数,如果该数为1-7,打印对应的星期,否则打印非法参数。
                 */
                var today = parseInt(prompt('请输入1-7:'));
                    switch (today) {
                        case today = 1:
                            alert('星期一');
                            break;
                        case today = 2:
                            alert('星期二');
                            break;
                        case today = 3:
                            alert('星期三');
                            break;
                        case today = 4:
                            alert('星期四');
                            break;
                        case today = 5:
                            alert('星期五');
                            break;
                        case today = 6:
                            alert('星期六');
                            break;
                        case today = 7:
                            alert('星期日');
                            break;
                        default:
                            alert('非法参数')
                    }
            </script>
        <body>
        </body>
    </html>
    

    相关文章

      网友评论

          本文标题:if/switch练习

          本文链接:https://www.haomeiwen.com/subject/oyldxqtx.html