计算器的加法和乘法的实现

来源:互联网 发布:签名设计软件免费版 编辑:程序博客网 时间:2024/05/20 23:37
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style type="text/css">
        input{
        width: 100px;
        height: 30px;
        background: orange;
        color: blue;
        }
</style>
<script type="text/javascript">
            
            function jia(){
            var a,b,c,i,j;
                a=document.getElementById("div1").value;
                b=document.getElementById("div2").value;
                // c=document.getElementById("div3").value;
                for(i=0;i<a;i++)
                {
                
                }


                for(j=0;j<b;j++)
                {
               
                }
                
                c=i+j;
                alert(c);
            }
            function cheng(){
            var a,b,d;
                a=document.getElementById("div1").value;
                b=document.getElementById("div2").value;
                
                d=document.getElementById("div4").value;
     
                d=a*b;
            alert(d);
            }
</script>
</head>
<body>
     <input type="text" id="div1"> 
     <input type="text" id="div2">
     <input id="div3" type="button" value="+" onclick="jia()" >
     <input id="div4" type="button" value="*" onclick="cheng()">
</body>
</html>
0 0
原创粉丝点击