学着做了一个简单的计算器!记录记录!哈哈

<!DOCTYPE html>

<html>

<head>

<title>简单的计算器</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 <style type="text/css">

       input{width:100%}

    </style>

</head>

<body>

     <script type="text/javascript">

      function compute(obj)

      {

       obj.expr.value=eval(obj.expr.value)

      }

     var plus="+";

var minus="-";

var multiply="*";

var divide="/";

var decimal=".";

function enter(obj,string)

{

obj.expr.value+=string;

}

function cle(obj)

{

obj.expr.value='';

}

</script>

<form >

<table border=1>

<tr >

<td colspan="4"><input type="text" name="expr" size="30"  style="width:97%"></td>

</tr>

<tr>

<td><input type="button" value="7" onclick="enter(this.form,7)"></td>

<td><input type="button" value="8" onclick="enter(this.form,8)"></td>

<td><input type="button" value="9" onclick="enter(this.form,9)"></td>

<td><input type="button" value="/" onclick="enter(this.form,divide)"></td>

</tr>

<tr>

<td><input type="button" value="4" onclick="enter(this.form,4)"></td>

<td><input type="button" value="5" onclick="enter(this.form,5)"></td>

<td><input type="button" value="6" onclick="enter(this.form,6)"></td>

<td><input type="button" value="*" onclick="enter(this.form,multiply)"</td>

</tr>

<tr>

<td><input type="button" value="1" onclick="enter(this.form,1)"></td>

<td><input type="button" value="2" onclick="enter(this.form,2)"></td>

<td><input type="button" value="3" onclick="enter(this.form,3)"></td>

<td><input type="button" value="-" onclick="enter(this.form,minus)"></td>

</tr>

<tr>

<td colspan="2"><input type="button" value="0" onclick="enter(this.form,0)"></td>

<td><input type="button" value="." onclick="enter(this.form,decimal)"></td>

<td><input type="button" value="+" onclick="enter(this.form,plus)"></td>

</tr>

<tr>

<td colspan="2" ><input type="button" value="=" onclick="compute(this.form)" ></td>

<td colspan="2"><input type="button" value="AC" size=3 onclick="cle(this.form)"></td>

</tr>

</table>

</form>

</body>

</html>

js制作简单的计算器的更多相关文章

  1. JS——制作简单的网页计算器

    用JS做了一个简易的网页计算器 <!DOCTYPE html> <html lang="en"> <head> <meta charset ...

  2. 用JavaScript制作简单的计算器

    <html > <head> <title>简单计算器</title> <style type="text/css"> ...

  3. 【前端】Vue.js实现简单价格计算器

    价格计算器 实现效果: 实现代码及注释: <!DOCTYPE html> <html> <head> <title>价格计算器</title> ...

  4. d3.js 制作简单的俄罗斯方块

    d3.js是一个不错的可视化框架,同时对于操作dom也是十分方便的.今天我们使用d3.js配合es6的类来制作一个童年小游戏--俄罗斯方块.话不多说先上图片. 1. js tetris类 由于方法拆分 ...

  5. d3.js 制作简单的贪吃蛇

    d3.js是一个不错的可视化框架,同时对于操作dom也是十分方便的.今天我们使用d3.js配合es6的类来制作一个童年小游戏–贪吃蛇.话不多说先上图片. 1. js snaker类 class Sna ...

  6. 利用css+原生js制作简易钟表

    利用css+原生js制作简单的钟表.效果如下所示 实现该效果,分三大块:html.javascript.css html部分html部分比较简单,定义一个clock的div,内部有原点.时分秒针.日期 ...

  7. JS制作图片切换

    <!DOCTYPE html> <html> <head> <title>纯JS制作简单的图片切换</title> <meta cha ...

  8. 留念 C语言第一课简单的计算器制作

    留念 C语言第一课简单的计算器制作 学C语言这么久了.  /* 留念 C语言第一课简单的计算器制作 */   #include<stdio.h>  #include<stdlib.h ...

  9. JS实现一个简单的计算器

    使用JS完成一个简单的计算器功能.实现2个输入框中输入整数后,点击第三个输入框能给出2个整数的加减乘除.效果如上: 第一步: 创建构建运算函数count(). 第二步: 获取两个输入框中的值和获取选择 ...

随机推荐

  1. postman插件安装教程

    第一步: 第二步: 第三步: 这样就可以了. 插件下载链接: http://pan.baidu.com/s/1eRVLMpk 密码: 49vb

  2. asp.net mvc adminlte第一波

    首页模板选用官方DEMO中的Blank模板,这个模板相对来说是最干净的. 首页模板的分割: 官方文档是分的4个部分 Wrapper .wrapper. A div that wraps the who ...

  3. ECMA中的switch语句

    switch借鉴自其他语言,但也有自己的特色. 1.可以在switch语句中使用任何数据类型(数值.字符串.对象等),很多其他语言中只能使用数值. 2.每个case的值不一定是常量,可以是变量或者表达 ...

  4. Javascript:谈谈JS的全局变量跟局部变量

    原文链接:http://blog.csdn.net/zyz511919766/article/details/7276089# 今天公司一个实习小妹子问我两段JS代码的区别: <script t ...

  5. 简单介绍一下R中的几种统计分布及常用模型

    统计学上分布有很多,在R中基本都有描述.因能力有限,我们就挑选几个常用的.比较重要的简单介绍一下每种分布的定义,公式,以及在R中的展示. 统计分布每一种分布有四个函数:d――density(密度函数) ...

  6. python之路2(基础详解)

    python一切都是对象: 列子:

  7. 封装的ajax请求

    在做登录注册这类提交表单数据时,我们经常需要局部刷新网页来验证用户输入的信息,这就需要用到ajax请求,我们通常需要获取表单中的数据,发起ajax请求,通过服务程序,与数据库的数据进行比对,判断信息的 ...

  8. td在relative模式下,IE9不显示border

    方法一 .thisTd {    background-clip: padding-box;     position:relative; } 方法二 .thisTd {   z-index=-1; ...

  9. ubuntu12.04 安装 QQ

    友情提示:QQ对于第三方平台封杀已经到了丧心病狂的程度,所以不要妄想在linux的QQ能像win系统下的效果,只能祈求能用就好 1.下载QQ安装包 http://pan.baidu.com/s/1ge ...

  10. 单据UI代码开发

    1.构造UI项目后,打开生成的UI项目代码,在Model文件下,如初始化一些字段的值 2.订单明细行中行号设置.订单基本操作按钮提示UFIDA.U9.Base.BaseBP.Agent.dll(代理) ...