zoukankan      html  css  js  c++  java
  • 真不知道起什么名字了

      hi

    早上好,难得早上能见到太阳,虽然昨晚睡得不太平,原因都还不知道,可能,是低开高走吧。

    昨天刚好完成任务,还不错,继续保持并多一点吧亲~

    上班去了

    -----------------08:53-------------------

    1、JS

    -判断类型语句练习

    <!DOCTYPE  HTML>
    <html >
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>函数</title>

    <script type="text/javascript">

    //定义函数
    function bothmax(a,b){
        if(a>b){
            maxo=a;
        }else if(b>a){
            maxo=b;
        }else{
            maxo="两个数字相等";
        }
        return maxo;
    }

    //函数体,判断两个整数比较的三种情况
    re1=bothmax(5,4);
    re2=bothmax(6,3);
     
    //调用函数,实现下面两组数中,返回较大值。
      document.write(" 5 和 4 的较大值是:"+re1+"<br>");
      document.write(" 6 和 3 的较大值是:"+re2 );
    </script>
    </head>
    <body>
    </body>
    </html>

    -事件:onclick="function_name()"

    类似的还有onmouseover,onmouseout,onblur,onfocus,onselect

    <!DOCTYPE html>
    <html>
     <head>
      <title> 事件</title>  
      <script type="text/javascript">
       function count(){   
            var txt1   = parseInt( document.getElementById('txt1').value);//获取第一个输入框的值
            var txt2   = parseInt( document.getElementById('txt2').value);//获取第二个输入框的值
            var select = document.getElementById('select').value;//获取选择框的值
            var result = '';
            switch (select)
             {
                case '+':
                    result = txt1 + txt2;
                    break;
                case '-':
                    result = txt1 - txt2;
                    break;
                case '*':
                    result = txt1 * txt2;
                    break;
                case '/':
                    result = txt1 / txt2;
                    break;  
             }
             document.getElementById('fruit').value = result;//设置结果输入框的值
       }
      </script>
     </head>
     <body>
       <input type='text' id='txt1' />
       <select id='select'>
            <option value='+'>+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="/">/</option>
       </select>
       <input type='text' id='txt2' />
       <input type='button' value=' = ' onclick="count()"/> <!--通过 = 按钮来调用创建的函数,得到结果-->
       <input type='text' id='fruit' />   
     </body>
    </html>

    --------------16:47-----------------

  • 相关阅读:
    【leetcode】11. 盛最多水的容器
    【leetcode】8. 字符串转换整数 (atoi)
    【leetcode】6. Z 字形变换
    【leetcode】5. 最长回文子串
    【leetcode】LCP 19. 秋叶收藏集
    删除第一个节点问题
    问一个大学学习计算机这门专业的问题
    Struts文件上传页面上传后显示“连接已重置”
    2013-12-6 思杨没吃饱 饿醒了
    2013-12-7 snoopy乐园中的思杨
  • 原文地址:https://www.cnblogs.com/andy1202go/p/4876401.html
Copyright © 2011-2022 走看看