弹窗运算符实例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>运算</title>
</head>
<body>
<button onclick="myFunction()">点我</button>
<p id="demo"></p>
<script>
function myFunction(){
	var person=prompt("1请输入数字","200");
	if (person!=null && person!=""){
		var person1=prompt("2请输入运算符加+减-乘*除/","/");
		if (person1!=null && person1!=""){
			var person2=prompt("3请输入数字","2");
			if (person2!=null && person2!=""){
				if (person1=="+"){
					x=person+person2;
				}else if(person1=="-"){
					x=person-person2; 
				}else if(person1=="*"){
					x=person*person2; 
				}else if(person1=="/"){
					x=person/person2; 
				}
				document.getElementById("demo").innerHTML=x;
			}
		}
		
		
	}
}
</script>

</body>
</html>


评论 (0)

最新评论(0)
评 论

你来打破零评论

Copyright ©2021 115cms综合内容管理系统 V4.04All Rights Reserved.