-3
document.getElementById("txtOutput").value = result;

instead of using .value=result, can I write something else to say, rewrite to a specific div or paragraph?

j08691
  • 204,283
  • 31
  • 260
  • 272
  • I did not catch your question? – MIIB Mar 06 '13 at 19:44
  • There are a bajillion duplicates of this, as well as an almost uncountable number of resources elsewhere on the internet. Do some basic research next time, for everyone's sake :) Voting to close as dup. – Chris Baker Mar 06 '13 at 19:51

3 Answers3

1

If you want to write something (including html-formatations) you can use innerHTML orherwise if you need only the text use innerText:

innerHTML

document.getElementById("txtOutput").innerHTML = result

innerText

document.getElementById("txtOutput").innerText = result;
yckart
  • 32,460
  • 9
  • 122
  • 129
1

Yes you can. Look at this simple JsFiddle for an example.

HTML:

<div id="me">
    <span>old stuff</span>
</div>

Script

document.getElementById('me').innerHTML = "new stuff";
Kyle Weller
  • 2,533
  • 9
  • 35
  • 45
0

you can use innerHTML:

 document.getElementById("txtOutput").innerHTML = 'some content';
Atep
  • 466
  • 13
  • 20