0

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 1

2
document.getElementById('foobox').value = foo; // for an input

document.getElementById('foobox').innerText = foo; // for a div
Sign up to request clarification or add additional context in comments.

2 Comments

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?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.