<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta charset="utf-8" />
</head>
<body>
<input id="num1" />+<input id="num2" /><input type="button" id="compute" value="=" /><input id="result" />
<script type="text/javascript">
window.onload = function () {
var btn = document.getElementById('compute');
btn.onclick = function () {
var result = parseInt(document.getElementById('num1').value) + parseInt(document.getElementById('num2').value);
document.getElementById('result').value = result;
};
};
</script>
</body>
</html>
加法计算器(parseInt())
最新推荐文章于 2021-12-02 20:30:20 发布