zoukankan      html  css  js  c++  java
  • 勾股定理

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
            <input type="text" value="" id="num1"/>
            <span>+</span>
            <input type="text" value="" id="num2"/>
            <span>=</span>
            <input type="text" value="" id="num3"/>
        </body>
    </html>
    <script>
        var oNum1 = document.getElementById( "num1" );
        var oNum2 = document.getElementById( "num2" );
        var oNum3 = document.getElementById( "num3" );
        //判断num1和num2是否为空
        function num(){
    if( oNum1.value == "" || oNum2.value == ""){
       oNum3.value = "输入的数值不能为空"
    }else{
    oNum3.value = Math.sqrt(Math.pow((oNum1.value),2)+Math.pow(Number(oNum2.value),2));
    }
        }
        oNum1.onfocus = function(){
            num();
                oNum2.onfocus = function(){
                    num();
                }
        }
    oNum2.onkeyup = function(){
          num();
                oNum1.onkeyup = function(){
                    num();
                }
    }

    </script>
  • 相关阅读:
    python for test
    python链接mysql pymysql
    MongoDB数据表添加字段
    NodeVisitor
    无法解决的错误
    一个点绕着另一个点旋转一定角度后的坐标
    2.0版本里程碑,研发日志
    osg Node getParentalNodePaths()报错
    TeslaManage 2.0编译日志
    机械臂模拟2.0
  • 原文地址:https://www.cnblogs.com/tis100204/p/10319237.html
Copyright © 2011-2022 走看看