手机版

js html实现计算器功能

时间:2021-08-28 来源:互联网 编辑:宝哥软件园 浏览:

本文实例为大家分享了超文本标记语言实现计算器功能的具体代码,供大家参考,具体内容如下

代码:

!DOCTYPE html html head meta charset=' utf-8 '/title/title script type=' text/JAVAScript ' var numresult;var strfunction onlicknum(nums){ str=document。GetElementByID(' nummessage ');字符串。值=字符串。值nums}函数onclickclear(){ str=document。getelementbyid(' nummessage ');str.value=}函数onclickresult(){ str=document。getelementbyid(' nummessage ');numresult=eval(str。值);str . value=numresult }/script/head body bgcolor=' AFFF '!-定义按键表格,每个按键对应一个事件触发-表格边框=' 1 ' align=' center ' bgColor=' # bbff 77 ' style=' height : 350 px;宽度: 270px' tr td colspan='4 '输入类型=' text ' id=' number ' style=' height : 90 px;宽度: 350像素;字号: 50px '/TD/tr TD输入类型='按钮'值=' 1 ' id=' 1 ' onclick=' onlicknum(1)' style=' height : 70px;宽度: 90px字号: 35px/TD TD输入类型='按钮'值=' 2 ' id=' 2 ' onclick=' onlicknum(2)' style=' height : 70px;宽度: 90pxfont-size : 35px/' TD TD TD输入类型=' button '值=' 3 ' id=' 3 ' onclick=' onlicknum(3)' style=' height : 70px;宽度: 90px字号: 35px/TD TD输入类型=' button ' value=' id=' add ' onclick=' onlicknum(')style=' height : 70px;宽度: 90pxfont-size: 35px' /td /tr tr td输入类型='按钮'值=' 4 ' id=' 4 ' onclick=' onlicknum(4)' style=' height : 70px;宽度: 90px字号: 35px/TD TD输入类型='按钮'值=' 5 ' id=' 5 ' onclick=' onlicknum(5)' style=' height : 70px;宽度: 90px字号: 35px/TD TD输入类型='按钮'值=' 6 ' id=' 6 ' onclick=' onlicknum(6)' style=' height : 70px;宽度: 90px字号: 35px/TD TD输入类型=' button ' value='-' id=' sub ' onclick=' onlicknum('-')' style=' height : 70px;宽度: 90pxfont-size: 35px' /td /tr tr td输入类型=' button ' value=' 7 ' id=' 7 ' onclick=' onlicknum(7)' style=' height : 70px;宽度: 90px字号: 35px/TD TD输入类型='按钮'值=' 8 ' id=' 8 ' onclick=' onlicknum(8)' style=' height : 70px;宽度: 90px字号: 35px/TD TD输入类型='按钮'值=' 9 ' id=' 9 ' onclick=' onlicknum(9)' style=' height : 70px;宽度: 90px字号: 35px/TD TD输入类型=' button ' value=' * ' id=' mul ' onclick=' onlicknum '(*)style=' height : 70px;宽度: 90pxfont-size : 35px '/TD/tr TD colspan=' 2 '输入类型='按钮'值=' 0 ' id=' 0 ' onclick=' onlicknum(0)' style=' height : 70px;宽度: 190像素;字号: 35px '/TD TD TD输入类型='按钮'值=',' id=' point ' onclick=' onclicknum(' .)' style=' height: 70px宽度: 90px字号: 35px/TD TD输入类型=' button ' value='/' id=' division ' onclick=' onlicknum '(/')' style=' height : 70px;宽度: 90pxfont-size : 35px '/TD/tr TD colspan=' 2 '输入类型='按钮'值=' Del ' id=' clear ' onclick=' onclickclear()' style=' height : 70px;宽度: 190像素;font-size : 35px '/TD TD TD col span=' 2 '输入类型='按钮'值='=' id=' result ' onclick=' onclick result()' style=' height : 70px;宽度: 190像素;font-size : 35px '/TD/tr/table/body/html效果图

以上就是本文的全部内容。希望对大家的学习有帮助,支持我们。

版权声明:js html实现计算器功能是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。