<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>dom</title>
<script type="text/JavaScript">
function count(){
var tex1=document.getElementById("tex1").value;
var tex2=document.getElementById("tex2").value;
var select=document.getElementById("select").value;
var result="";
switch(select)
{
case "+":
result=parseFloat(tex1)+parseFloat(tex2);
break;
case "-":
result=parseFloat(tex1)-parseFloat(tex2);
break;
case "*":
result=parseFloat(tex1)*parseFloat(tex2);
break;
default "/":
result=parseFloat(tex1)/parseFloat(tex2);
break;
}
document.getElementById("jieguo").value=result;
}
</script>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
<input type="text" value="" id="tex1">
<select name="" id="select">
<option value="">+</option>
<option value="">-</option>
<option value="">*</option>
<option value="">/</option>
</select>
<input type="text" value="" id="tex2">
<input type="button" value="=" onClick="count()" />
<input type="text" value="" id="jieguo">
</body>
</body>
</html>
Caballarii
相关分类