标签:html document head ber nbsp body 输入 result diff
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="test" id="n1" value="" />
<input type="test" id="n2" value="" />
<input type="submit" id="d1" value="count" onclick="result()"/>
</body>
<script>
function result(){
var a1=document.getElementById("n1");
var a2=document.getElementById("n2");
var b1=Number(a1.value)+Number(a2.value);
var b2=Number(a1.value)-Number(a2.value);
var b3=Number(a1.value)*Number(a2.value);
var b4=Number(a1.value)%Number(a2.value);
alert("And"+b1+"\n"+"Difference"+b2+"\n"+"Product"+b3+"\n"+"Remainder"+b4)
}
</script>
</html>
JS写一个简单的程序,输入两个整数,打印这两个数的和,差,积,余数
标签:html document head ber nbsp body 输入 result diff
原文地址:http://www.cnblogs.com/niuniudashijie/p/5987820.html