js简写计算器
来源:互联网 发布:淘宝裱画工具 编辑:程序博客网 时间:2024/05/07 15:02
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var flag = true;
function getNum(num){
if(!flag){
document.getElementById('res').value = '';
flag = true;
}
document.getElementById('res').value +=num;
}
function getRes(){
var num = document.getElementById('res').value;
num = eval(num);
document.getElementById('res').value = num;
flag = false;
}
</script>
</head>
<body>
<table width="300px" border="1px">
<caption>简易计算器</caption>
<tr>
<td colspan="4"><input type="text" size="53" id="res" /></td>
</tr>
<tr>
<td><input type="button" value="1" style="width:75px;" onclick="getNum(1)" /></td>
<td><input type="button" value="2" style="width:75px;" onclick="getNum(2)"/></td>
<td><input type="button" value="3" style="width:75px;" onclick="getNum(3)"/></td>
<td><input type="button" value="+" style="width:75px;" onclick="getNum('+')"/></td>
</tr>
<tr>
<td><input type="button" value="4" style="width:75px;" onclick="getNum(4)"/></td>
<td><input type="button" value="5" style="width:75px;" onclick="getNum(5)"/></td>
<td><input type="button" value="6" style="width:75px;" onclick="getNum(6)"/></td>
<td><input type="button" value="-" style="width:75px;" onclick="getNum('-')"/></td>
</tr>
<tr>
<td><input type="button" value="7" style="width:75px;" onclick="getNum(7)"/></td>
<td><input type="button" value="8" style="width:75px;" onclick="getNum(8)"/></td>
<td><input type="button" value="9" style="width:75px;" onclick="getNum(9)"/></td>
<td><input type="button" value="*" style="width:75px;" onclick="getNum('*')"/></td>
</tr>
<tr>
<td><input type="button" value="0" style="width:75px;" onclick="getNum(0)"/></td>
<td><input type="button" value="." style="width:75px;" onclick="getNum('.')"/></td>
<td><input type="button" value="=" style="width:75px;" onclick="getRes('=')"/></td>
<td><input type="button" value="/" style="width:75px;" onclick="getNum('/')"/></td>
</tr>
</table>
</body>
</html>
- js简写计算器
- JS function简写
- js简写技巧
- easyjweb-util.js中的简写
- JS简写技巧必知!!
- js -计算器
- js计算器
- js计算器
- JS计算器
- js计算器
- js计算器
- JS计算器
- js计算器
- js 计算器
- js计算器
- js计算器
- js 计算器
- js计算器
- 微信sdk超级简单demo
- Moto XT532 获取root权限,以及系统附带软件的删除。
- chapter 3: 内核对象
- 写在开学前,写在七夕时,写给俱乐部,写给大一新生
- 字符串移位包含的问题
- js简写计算器
- OpenSSH构建SSH服务器
- [Gstreamer][Bash Script]转换任意视频到ios支持的mp4文件格式
- 悲催的海外主机!!!!
- 多终端时代:云开放api将成为互联网最重要的基础组件
- “开源3D软件--blender”讲座暨“激情与梦想——我的程序员之路”2012年CSDN全国高校巡讲
- 电子科技大学CSDN高校俱乐部:浅谈计算机与数学——ACM总教练杨鹏老师讲座
- 计算机是怎么启动起来的?
- hdu Pixel density 2411