Juan Juan - 1 year ago 62
HTML Question

Setting Value of Output Element via JavaScript in Edge and IE

I have an

tag whose value is set dynamically via JavaScript. This works just fine in Chrome and Firefox, but Microsoft browsers (IE and Edge) don't seem to recognize it, and the
is always empty for these tags.


document.getElementById("owned").value = "Test 1";
document.getElementById("used").value = "Test 2";

<output class="output" id="owned"></output>
<output class="output" id="used"></output>

It even works when I run the code snippet on Stack Overflow.

Question: Is there any reason why the values aren't being set on these browsers? Is there a file that I must import into my HTML for it to work on IE/Edge?

Answer Source

Use span and .innerHTML. <output> HTML tag seems to not work on Edge.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download