I have a int foo in my JavaScript program that changes many times. I want to display the current value of foo in #foobox, replacing the old value. How can I do this?
1 Answer
document.getElementById('foobox').value = foo; // for an input
document.getElementById('foobox').innerText = foo; // for a div
2 Comments
user3324865
I do that and foobox looks like this: <div id="foobox" value=""></div> but nothing is displayed. How do I make the value of foobox be displayed in the html?
user3324865
I tried with innerText and couldn't understand why it didn't work. I googled "innerText" and found it's only for internet explorer. The !IE equivalent is textContent, which works for me. Thanks for your input! Problem solved now. Update your answer to include this information and I will mark it as solution.