• 实训篇-Html-计算器


    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8">
    		<title></title>
    		<!--给button添加样式-->
    		<style type="text/css">
    			input[type=button]{
    				 95px;
    				height: 75px;
    			}
    		</style>
    		
    		<script type="text/javascript">
    		//点击按钮的时候 触发执行的方法
    			function clickNum(num){
    				var inp =document.getElementById("num");
    				switch(num){
    					//清空输入框内容
    					case"c":inp.value="";
    					break;
    					case"=":
    					inp.value=eval(inp.value);
    					break;
    					//将点击的按钮的内容连接到输入框的
    					default:inp.value+=num;
    					break;
    				}
    			}
    		</script>
    	</head>
    	<body>
    		<br />
    		<br />
    		<br />
    		<center>
    		<div style="470px;height: 620px;border: solid 1px black; ">
    		
    				<input type="text"id="num"style=" 400px;height: 70px;"/>
    			<br /><br />
    			<input type="button" name="" id="" value="1" onclick="clickNum(this.value)"/>
    			<input type="button" name="" id="" value="2" onclick="clickNum(this.value)"/>
    			<input type="button" name="" id="" value="3" onclick="clickNum(this.value)" />
    			<input type="button" name="" id="" value="+" onclick="clickNum(this.value) "/>
    			<br /><br />
    			<input type="button" name="" id="" value="4" onclick="clickNum(this.value)" />
    			<input type="button" name="" id="" value="5" onclick="clickNum(this.value)" />
    			<input type="button" name="" id="" value="6" onclick="clickNum(this.value)" />
    			<input type="button" name="" id="" value="-" onclick="clickNum(this.value)"/>
    			<br /><br />
    			<input type="button" name="" id="" value="7" onclick="clickNum(this.value)" />
    			<input type="button" name="" id="" value="8" onclick="clickNum(this.value) "/>
    			<input type="button" name="" id="" value="9" onclick="clickNum(this.value) "/>
    			<input type="button" name="" id="" value="*" onclick="clickNum(this.value)"/>
    			<br /><br />
    			<input type="button" name="" id="" value="c"  onclick="clickNum(this.value)"/>
    			<input type="button" name="" id="" value="0"  onclick="clickNum(this.value)"/>
    			<input type="button" name="" id="" value="="  onclick="clickNum(this.value)"/>
    			<input type="button" name="" id="" value="/"  onclick="clickNum(this.value)"/>
    		</div>
    		</center>
    		
    	</body>
    </html>
    

      

  • 相关阅读:
    [RN] React Native 中使用 stickyHeaderIndices 实现 ScrollView 的吸顶效果
    [PHP] layui实现多图上传,图片自由排序,自由删除
    [RN] React Native 下拉放大动画
    [RN] React Native 实现 多选标签
    [RN] React Native 让 Flatlist 支持 选中多个值,并获取所选择的值
    [RN] React Native代码转换成微信小程序代码的转换引擎工具
    【python小练】0004
    【python小练】0001
    【python小练】0000
    【LeetCode】108. Convert Sorted Array to Binary Search Tree
  • 原文地址:https://www.cnblogs.com/52dxer/p/12165199.html
Copyright © 2020-2023  润新知