HTML+CSS+Javascript 实现简单计算器
来源:互联网 发布:陌陌一键打招呼软件 编辑:程序博客网 时间:2024/06/05 19:12
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>简单计算器</title> <style> *{ box-sizing: border-box; } .mycalculator{ border: 2px solid black; width: 300px; border-radius: 30px; background-color:burlywood; padding-left: 60px; margin:auto; margin-top: 150px; box-shadow:5px 5px gray; } .wenben{ size:15px; } .buto{ width:40px; height:40px; margin: inherit; } .operator{ width:40px; height:40px; margin: inherit; } .buto,.wenben,.operator{ border-radius:10px; } #display{ height:40px; background-color: #98d1dc; box-shadow:inset 5px 5px darkolivegreen; } </style></head><body> <div class="mycalculator"> <h3>by 一笑而过</h3> <form class="calculator"> <input type="button" class="operator" id="clear" value="清空"> <!--清空display中的内容--> <input type="text" id="display"> <!--文本框--> <br> <input type="button" class="buto" value="7" onclick="getvalue(this.value)"> <input type="button" class="buto" value="8" onclick="getvalue(this.value)"> <input type="button" class="buto" value="9" onclick="getvalue(this.value)"> <input type="button" class="operator" value="+" onclick="getvalue(this.value)"> <br> <input type="button" class="buto" value="4" onclick="getvalue(this.value)"> <input type="button" class="buto" value="5" onclick="getvalue(this.value)"> <input type="button" class="buto" value="6" onclick="getvalue(this.value)"> <input type="button" class="operator" value="-" onclick="getvalue(this.value)"> <br> <input type="button" class="buto" value="1" onclick="getvalue(this.value)"> <input type="button" class="buto" value="2" onclick="getvalue(this.value)"> <input type="button" class="buto" value="3" onclick="getvalue(this.value)"> <input type="button" class="operator" value="*" onclick="getvalue(this.value)"> <br> <input type="button" class="buto" value="0" onclick="getvalue(this.value)"> <input type="button" class="operator" value="." onclick="getvalue(this.value)"> <input type="button" class="operator" value="/" onclick="getvalue(this.value)"> <input type="button" class="operator" id="result" value="="> <br> </form> </div> <script> var body_Element = document.getElementsByTagName("body")[0]; document.getElementById("clear").onclick = function() { document.getElementById("display").value=""; }; function getvalue(value){ document.getElementById("display").value += value; } document.getElementById("result").onclick = function() { var answer = 0; answer = document.getElementById("display").value; document.getElementById("display").value = ""; document.getElementById("display").value = eval(answer); //计算表达式或者语句 }; </script></body></html>
阅读全文
0 0
- HTML+CSS+Javascript 实现简单计算器
- 用HTML、CSS、JavaScript 实现一个简单的计算器
- HTML&&JavaScript实现一个简单的计算器
- HTML实现简单计算器
- javascript实现简单计算器
- html和javascript实现计算器
- html javascript css写简易计算器
- HTML+CSS+JS 简单的计算器
- javascript实现的简单计算器
- javascript实现的简单计算器
- javascript简单计算器的实现
- javascript实现简单的计算器
- javascript实现的简单计算器
- 用javascript实现简单计算器
- JavaScript实现简单的计算器
- html+js+css实现计算器功能
- HTML+CSS+JavaScript实现简单的二级菜单
- html+javascript+css简单例子
- MFC学习笔记3 Windows编程基础--DialogBox、回调、消息、控件
- Hibernate创建对象-关系映射文件和数据库
- Hibernate创建持久化类
- 深搜例题
- Hibernate使用JUnit进行测试
- HTML+CSS+Javascript 实现简单计算器
- hibernate配置文档
- hibernate常用配置
- hibernate的session简介
- 批量生成idapro的Sig文件
- mariadb与mysql
- hibernate的transaction简介
- hibernate之如何获得session对象
- hibernate的hbm配置文档