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

<!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. Problems with MMM for mysql(译文)

    Problems with mmm for mysql posted in MySQL by shlomi 原文:http://code.openark.org/blog/mysql/problems ...

  2. 数据分析 - 斯特鲁普效应(Stroop effect)

    数据分析 - 斯特鲁普效应(Stroop effect) Reinhard得到了一份斯特鲁普效应试验的数据,我们来分析下,文字的颜色,是否会影响受试者的反应. 这里先看看什么是斯特鲁普效应: 斯特鲁普 ...

  3. Comparable和Comparator的区别

    Comparable Comparable可以认为是一个内比较器,实现了Comparable接口的类有一个特点,就是这些类是可以和自己比较的,至于具体和另一个实现了Comparable接口的类如何比较 ...

  4. cookie 的创建 得到 删除

    //设置cookie function setCookie(attr,value,time){ if(time){ var newtime=new Date(); newtime.setTime(ne ...

  5. C#调用RAR压缩与解压

    public void RARsave(string rarPatch, string rarFiles,string  patch,string rarName)        {          ...

  6. Mybatis Generator生成工具配置文件详解

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...

  7. C/C++ 堆和栈的区别

    堆和栈的区别 一个由C/C++编译的程序占用的内存分为以下几个部分 1.栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等.其 操作方式类似于数据结构中的栈. 2.堆区(h ...

  8. Android first --- 网络编程

    网络编程 ###图片下载查看 1.发送http请求 URL url = new URL(address); //获取连接对象,并没有建立连接 HttpURLConnection conn = (Htt ...

  9. 闲的写写SQL

    /* 新增 */ Create Proc AddData ( ), ), @Values nvarchar(max) ) as declare @Sql nvarchar(max) declare @ ...

  10. kafka使用getOffsetsBefore()获取获取offset异常分析

    根据时间戳获取kafka的topic的偏移量,结果获取的偏移量量数据组的长度为0,就会出现如下的数组下标越界的异常,实现的原理是使用了kafka的getOffsetsBefore()方法: Excep ...