EDIT: WOW. This question is 12 years old now.
As someone stated, it can be done with a one-liner since 2016: https://mcmap.net/q/335761/-alternative-for-innerhtml
The original:
I'm wondering if there's a way to change the text of anything in HTML without using innerHTML.
Reason I'm asking is because it's kinda frowned upon by the W3C. I know it's nitpicking, but I just wanna know, is there a way?
EDIT: people seem to misunderstand what I'm asking here: I want to find a way to effectivly change the text being displayed.
If I have:
<div id="one">One</a>
innerHTML allows me to do this:
var text = document.getElementsById("one");
text.innerHTML = "Two";
And the text on my screen will have changed.
I do not wish to append more text, I wish to change allready existing text.
.innerHTML
and not.innerHtml
, Javascript (unlike PHP) is a case sensitive language. – Haberdasher