html编写输入被除数和除数,单击等号按钮,在后面两个编辑框中显示商和余数
展开全部
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<style type="text/css">
input{width: 35px; text-align: right; padding-right: 5px;}
#oper{text-align: center;}
</style>
</head>
<body>
<input type="text" id="num1" />
<label>÷</label>
<input type="text" id="num2" />
<input type="button" id="oper" value="=" onclick="operation()"/>
<input type="text" id="num3" value="" />
<span>...</span>
<input type="text" id="num4" value="" />
</body>
<script type="text/javascript">
var num1 = document.getElementById("num1");
var num2 = document.getElementById("num2");
function operation(){
var result = parseInt(num1.value/num2.value);
var rem = num1.value%num2.value;
document.getElementById("num3").value = result;
document.getElementById("num4").value = rem;
}
</script>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<style type="text/css">
input{width: 35px; text-align: right; padding-right: 5px;}
#oper{text-align: center;}
</style>
</head>
<body>
<input type="text" id="num1" />
<label>÷</label>
<input type="text" id="num2" />
<input type="button" id="oper" value="=" onclick="operation()"/>
<input type="text" id="num3" value="" />
<span>...</span>
<input type="text" id="num4" value="" />
</body>
<script type="text/javascript">
var num1 = document.getElementById("num1");
var num2 = document.getElementById("num2");
function operation(){
var result = parseInt(num1.value/num2.value);
var rem = num1.value%num2.value;
document.getElementById("num3").value = result;
document.getElementById("num4").value = rem;
}
</script>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询