-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
  • 197,815
  • 30
  • 248
  • 265
  • 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
  • 30,290
  • 9
  • 117
  • 125
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,423
  • 8
  • 33
  • 45
0

you can use innerHTML:

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