首页 / 知识
HTML和JS实现简单的计算器
2023-04-11 15:11:00
<!doctypehtml>
<html>
<head>
<metacharset="utf-8">
<title>无标题文档</title>
<linkrel="stylesheet"type="text/css"href="untitled.css">
</head>
<scripttype="text/javascript">
varresult="";
functionjisuan(num){
if(num=="="){
document.form1.text.value=eval(result);
}else{
result=result+num;
document.form1.text.value=result;
}
}
</script>
<body>
<pclass="box">
<formaction=""class="form1"name="form1">
<pclass="header">
<inputtype="text"id="text"name="text"class="text"/>
</p>
<pclass="nav">
<tableclass="table">
<tr>
<td><inputid="1"style="height:55px;width:55px;"type="button"value="1"onClick="jisuan(this.id)"/></td>
<td><inputid="2"style="height:55px;width:55px;"type="button"value="2"onClick="jisuan(this.id)"/></td>
<td><inputid="3"style="height:55px;width:55px;"type="button"value="3"onClick="jisuan(this.id)"/></td>
<td><inputid="+"style="height:55px;width:55px;"type="button"value="+"onClick="jisuan(this.id)"/></td>
</tr>
<tr>
<td><inputid="4"style="height:55px;width:55px;"type="button"value="4"onClick="jisuan(this.id)"/></td>
<td><inputid="5"style="height:55px;width:55px;"type="button"value="5"onClick="jisuan(this.id)"/></td>
<td><inputid="6"style="height:55px;width:55px;"type="button"value="6"onClick="jisuan(this.id)"/></td>
<td><inputid="-"style="height:55px;width:55px;"type="button"value="-"onClick="jisuan(this.id)"/></td>
</tr>
<tr>
<td><inputid="7"style="height:55px;width:55px;"type="button"value="7"onClick="jisuan(this.id)"/></td>
<td><inputid="8"style="height:55px;width:55px;"type="button"value="8"onClick="jisuan(this.id)"/></td>
<td><inputid="9"style="height:55px;width:55px;"type="button"value="9"onClick="jisuan(this.id)"/></td>
<td><inputid="*"style="height:55px;width:55px;"type="button"value="*"onClick="jisuan(this.id)"/></td>
</tr>
<tr>
<td><inputid="/"style="height:55px;width:55px;"type="button"value="/"onClick="jisuan(this.id)"/></td>
<td><inputid="0"style="height:55px;width:55px;"type="button"value="0"onClick="jisuan(this.id)"/></td>
<td><inputid="."style="height:55px;width:55px;"type="button"value="."onClick="jisuan(this.id)"/></td>
<td><inputid="="style="height:55px;width:55px;"type="button"value="="onClick="jisuan(this.id)"/></td>
</tr>
</table>
</p>
</form>
</p>
</body>
</html>
本文转载自中文网 |
最新内容
相关内容
python如何读取列表中元素的位置?
python如何读取列表中元素的位置?,位置,数据,异常,培训,字符串,元素,索引,方法,示例,结果,python读取列表中元素位置的方法:1、使用index()方python中获取路径的三种方法
python中获取路径的三种方法,工作,代码,情况,培训,下来,路径,文件,也就是,桌面,目录,python中获取路径总结下来分为三种情况:1、获取工作目录python如何调用另一个文件夹中的内
python如何调用另一个文件夹中的内容?,系统,培训,文件,模块,内容,路径,函数,所在,前缀,语句,python中调用另外一个文件夹中的内容:1、同一文件如何在python代码中指定保存的文件
如何在python代码中指定保存的文件格式,代码,培训,文件格式,格式,二进制文件,文件,后缀,以上,方法,更多,python指定保存文件格式的方法:1、保Python如何复制文件中的内容
Python如何复制文件中的内容,盘中,数据,培训,文件,内容,方法,文件夹,路径,源文件,文件名,python复制文件中内容的方法:1、使用shutil.copyfilepython的闭包函数是什么
python的闭包函数是什么,代码,工作,函数,培训,程序,外部,个数,变量,嵌套,赋值,python中的闭包,又称闭包函数或者闭合函数,其实和前面讲的嵌套函python的time怎么使用
python的time怎么使用,时间,平台,单位,实时,标准,培训,术语,模块,函数,精度,python中的time模块time这个模块提供各种与时间相关的函数。相关如何导入python的模块包
如何导入python的模块包,模块,环境,培训,系统,功能,别名,路径,顺序,文件,结尾,导入python的模块包的方法:模块实际上就是以.py为结尾的文件注python怎样求和
python怎样求和,培训,总和,参数,方法,列表,语法,实例,对象,以上,以下,python中的sum()方法可对系列进行求和计算。以下是sum()方法的语法:sumpython怎么处理json
python怎么处理json,培训,数据,数字,字符串,数据类型,字典,模块,之间,功能,文件,python的Json模块提供了四个功能:dumps、dump、loads、loadpipythonc语言取余和python取余的区
pythonc语言取余和python取余的区别,培训,资料,语言,负数,区别,被除数,符号,除数,规定,余数,今天看书发现python与C的负数取余运算结果不同,python如何定义接受参数的函数
python如何定义接受参数的函数,信息,培训,位置,参数,函数,列子,效果,定义,更多,内容,python中的函数可以有参数,也可以无参数,参数可以分为默认