欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

html5 外链式实现加减乘除

程序员文章站 2022-06-06 17:25:25
js代码: ......
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>加减乘除</title>
        <script src="a.js"></script>//引用js
    </head>
    <body>
        <p>a=3,b=2;</p>
        <input type="button" onclick="alert(sum(3,2))" value="加" />
        <input type="button" onclick="alert(jian(3,2))" value="减" />
        <input type="button" onclick="alert(cheng(3,2))" value="乘" />
        <input type="button" onclick="alert(chu(3,2))" value="除" />
    </body>
</html>

js代码:

function sum(a,b){
    var c;
    c=a+b;
    return c;
}
function jian(a,b){
    var c;
    c=a-b;
    return c;
}
function cheng(a,b){
    var c;
    c=a*b;
    return c;
}
function chu(a,b){
    var c;
    c=a/b;
    return c;
}