I have this tag in my HTML:
<p id="moneyvalue"></p>
And I have this Javascript code:
var moneyBalance = 0;
document.getElementById('moneyvalue').innerHTML=moneyBalance;
I have onclick=..., which causes functions to add to the moneyBalance variable. The problem is that the paragraph element with the moneyvalue id does not update until I call the last line of code I mentioned. Is there a way to constantly update the element without needing to call that line after every update I make to the moneyBalance variable, or is that the only way to do that?