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

<!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. Cellebrite UFED 5.1 发布,全面支持三星 S6 S6 Edge Note5 HUAWEI series

    世界级取证公司Cellebrite 昨天发布了最新的 UFED 5.1 系统更新,4PC全面支持三星S6,S6EDGE NOTE5 以及HUAWEI,LG系列恢复,锁屏密码XX!下面是部分截图 有需要 ...

  2. Oracle Grid Infrastructure安装部署文档

    1. 部署环境步骤 1.1 软件环境 操作系统: CentOS release 6.5 oracle安装包: linux.x64_11gR2_grid.zip linux.x64_11gR2_data ...

  3. sql中批量删除带有外键的所有表

    1首先删除所有的外检约束 --删除所有外键约束 DECLARE c1 cursor forselect 'alter table ['+ object_name(parent_obj) + '] dr ...

  4. 如何站在使用者的角度来设计SDK-微信公众号开发SDK(消息处理)设计之抛砖引玉

    0.SDK之必备的基本素质 在项目中免不了要用到各种各样的第三方的sdk,在我现在的工作中就在公司内部积累了各种各样的的公共库(基于.net的,基于silverlight的等等),托管到了内部的nug ...

  5. 课堂 一些代码的叫法 JavaScript js

    ():圆括号 {} :花括号 <>:尖括号 [] :方括号

  6. webapi aspose导出excel表格

    API 通过get请求,注意用到一个[FromUri]特性,使GET接收实体参数 /// <summary> /// 导出 /// </summary> /// <par ...

  7. 20-ES6(3)class基本语法

    # Class基本语法 关于es6的class简介: ES6提供了更接近传统语言的写法,引入了Class(类)这个概念,作为对象的模板.通过class关键字,可以定义类.基本上,ES6的class可以 ...

  8. HTTP 错误 403.14 - Forbidden Web 服务器被配置为不列出此目录的内容

    今天把一个.NET的网站部署到IIS上打开网页的时候出现了这个错误,刚开始以为是没有配置默认页,但是直接打开固定的页面地址也不行. 于是怀疑是.NET版本的问题,但是看了一下程序的目标框架是4.0没错 ...

  9. LookUpEditPopup自动调整宽度

    this.Properties.BestFitMode = BestFitMode.BestFitResizePopup;

  10. 如何将推送证书p12导出为pem

    1. 在Mac上启动Keychain助手,然后在login keychain中选择 Certificates分类.你将看到一个可展开的“Apple Development Push Services” ...