if...else

if…else 练习

这里写代码片
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>if..else</title>
        <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
        <style type="text/css">
            *{ margin: 0; padding: 0;}
            .content{ max-width: 900px;  height:100%;margin: 0 auto; background-color: #0C4B62; color: #fff;}
            .scoreBox{ height: 300px; display: flex; align-items: center; }
            .scoreBox>label{ line-height: 34px;;}
            .scoreBox>input{ height: 34px; line-height: 34px; padding-left:10px ; margin-right: 20px;}
            .scoreBox>span{ width:200px; display: inline-block; border-bottom:1px #fff solid ; height: 34px;; line-height: 34px;;}
            .scoreBox>span:after{ border: 1px #101010 solid; }
        </style>
    </head>
    <body>
        <div class="content">
            <div class="scoreBox">
                <label for="">小明的成绩:</label>
                <input type="number"  alt="输入成绩"/>
                <button onclick="score()">成绩优良</button>

                <span class="score"></span>
            </div>
            <div class="box1">

            </div>
        </div>
        <script type="text/javascript">
            function score(){

                var a=$("input[type='number']").val()/1;
                if(a<=100&&a>=0){   
                    if(a>=90){
                        $("span").text("成绩为优");
                    }
                    if(a<90&&a>80){
                        $("span").text("成绩为良好");
                    }
                    if( a<=80&&a>60){
                        $("span").text("成绩为及格");
                    }
                    if(a<=60){
                        $("span").text("成绩为不及格");
                    }
                }
                else{$("span").text("请输入0-100之间的数");}
            }
            function obj(point){
                alert("box的 横坐标为:"+point.x+"box的 纵坐标为:"+point.y);
            }

        </script>
    </body>
</html>

效果图
您在输入框中输入0-100之间的数字,点击 “成绩优良”按钮,得出相应的结果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值