码迷,mamicode.com
首页 > 其他好文 > 详细

自制计算器

时间:2018-02-18 20:21:21      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:img   mit   asc   tor   cli   meta   nis   ext   blog   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自制计算器</title>
    <script src="add.js" type="text/javascript"></script>
</head>
<body>
    <div align="center" style="margin-top: 60px">
        <img src="add.png">
    </div>
    <div align="center" style="margin-top: 80px">
        <form name="form1">
            <input type="text" name="add1" placeholder="add1">+
            <input type="text" name="add2" placeholder="add2">=
            <input type="text" readonly="readonly" name="result" placeholder="result">
            <input type="button" name="submit" value="计算" onclick="add()">
        </form>
    </div>

</body>
</html>


/**
 * Created by Administrator on 2018/2/18.
 */

function add() {
    var add1 = Number(document.form1.add1.value);
    var add2 = Number(document.form1.add2.value);
    var result = add1 + add2
    document.form1.result.value=result
}

 

自制计算器

标签:img   mit   asc   tor   cli   meta   nis   ext   blog   

原文地址:https://www.cnblogs.com/themost/p/8453107.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!