2019-06-12 计算器
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>计算器</title>
<script type="text/javascript">
window.onload = function(){
var in01 = document.getElementById('input01')
var in02 = document.getElementById('input02')
var sel = document.getElementById('select')
var bu = document.getElementById('btn')
var a1 = Number(in01.value)
bu.onclick =function(){
if(sel.value == '0'){
var result = Number(in01.value) +Number(in02.value);
alert(result);
}
else if(sel.value == '1'){
var result = Number(in01.value) - Number(in02.value);
alert(result);
}
else if(sel.value == '2'){
var result = Number(in01.value) * Number(in02.value);
alert(result);
}
else if(sel.value == '3'){
var result = Number(in01.value) / Number(in02.value);
alert(result);
}
}
}
</script>
</head>
<body>
<h1>计算器</h1>
<input type="text" name="" id="input01" />
<select id="select">
<option value="0">+</option>
<option value="1">-</option>
<option value="2">*</option>
<option value="3">/</option>
</select>
<input type="text" name="" id="input02" />
<input type="button" name="" value="计算" id="btn" onclick="javascript:button-onclick();"/>
</body>
</html>