Is there any way to change the value of DOM textNode in a web browser?
I specifically wanted to see if I could change an existing node, rather than create a new node.
To clarify, I need to use Javascript to accomplish this. All text in the browser is stored in #textNodes, which are children of other HTML nodes but cannot have children of their own.
As Ash answered below, the content can be changed by setting the nodeValue property of these objects.
I believe innerHTML is used for this purpose... then again, this is not W3C approved... but it works...
If you have a specific node (#text type) and want to change its value, you can use the nodeValue attribute:
Notice:
innerText (and
possiblytextContent) will return/set the current node and all descendant node text, so may not be the behavior you want/expect.