我想编写一个带有一个输入的程序,在其中输入数字。每次单击时,总和将由数字相加。这是我走的路,我基本上被困在这里。所以请帮助
buttonAdd.onclick = function () {
var inputTall = document.getElementById("inputTall").value;
var a = parseFloat(inputTall);
var b = 0;
var c = a + b;
document.getElementById("pOutput").innerHTML = c;
d = c + a;
document.getElementById("pOutput").innerHTML = d;
}
<!DOCTYPE html>
<html lang = "en-US">
<head>
<link rel="stylesheet" href="CSS/mystyles.css">
<meta charset = "UTF-8">
<title>oppgave 24</title>
<body>
<h1>Summer tall</h1>
<input id="inputTall">
<button id="buttonAdd";>Legg til</button>
<hr>
<br>
Nylig: <p id="nylig"></p>
<hr>
Sum: <p id= "pOutput"></p>
<script src="JS/code.js"></script>
</body>
</html>
如您所见,d = c + a不起作用,并且它使最后的总数加倍。
答案 0 :(得分:1)
如何将总数存储在全局变量中
class animals{}
class mammals extends animals{}
class dogs extends mammals{}