zoukankan      html  css  js  c++  java
  • js if 判断的使用

    !DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>同志交友</title>
    <style>
    input {
    300px;
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    }
    button {
    padding: 10px 20px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    }
    #res {
    margin-top:20px;
    300px;
    min-height: 100px;
    padding: 10px;
    border:1px solid #ccc;
    }

    </style>
    </head>
    <body>
    <h1>同志交友</h1>
    <hr>
    <h3>请输入您的成绩:</h3>
    <input type="number" id="score">
    <button onclick="makeScore()">提交</button>


    <div id="res"></div>


    <script>
    //声明函数
    function makeScore() {
    //获取用户输入的成绩
    var score = Number(document.getElementById('score').value);

    //对成绩进行判断
    var resContent = ''; //空字符串 声明定义 变量
    if (score >= 90) {
    resContent = '不错哦,小同志,很优秀'; //修改变量的值
    } else if (score >= 80) {
    resContent = '小同志,还行';
    } else if (score >= 60) {
    resContent = '小同志,及格了';
    } else {
    resContent = '你不是我的同志';
    }


    //把结果写入到div中 id=res
    document.getElementById('res').innerHTML = resContent;

    }

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

  • 相关阅读:
    1-5-03:均值
    1-5-01:求平均年龄
    1-04-t6993:二进制位处理
    1-4-20:求一元二次方程的根
    1-4-19:简单计算器
    1-4-18:点和正方形的关系
    1-4-17:判断闰年
    1-4-16:三角形判断
    1-4-15:最大数输出
    停止IIS服务
  • 原文地址:https://www.cnblogs.com/wuheng-123/p/9448982.html
Copyright © 2011-2022 走看看