document.getElementById("output1").innerHTML = totalDistance + ", " + hours + ":" + minutes+", $" + cost; this is taking all of the different parts of the input and putting it together to make the output基本上,我遇到的问题是尝试循环它,这样它就会根据用户的输入循环5次。我希望用户能够输入新值,然后单击按钮并输出到"output1“的下一行。目前,用户每次输入一组新的5个数字并单击按钮时,以前出现在"output1“中的数字都会消失。如果有任何帮助,可以让这个循环5次,我们将不胜感激。谢谢。
发布于 2020-11-22 01:45:27
这是因为您在每次运行函数时都会覆盖innerhtml输出。
替换函数中要追加的最后一行:
document.getElementById("output1").innerHTML += totalDistance + ", " + hours + ":" + minutes+", $" + cost + '<br>';https://stackoverflow.com/questions/64945830
复制相似问题