Change textNode value Change textNode value javascript javascript

Change textNode value


If you have a specific node (of type #text) and want to change its value you can use the nodeValue property:

node.nodeValue="new value";

Note:

innerText (and possibly textContent) will return/set both the current node and all descendent nodes text, and so may not be the behaviour you want/expect.


I believe innerHTML is used for this... Then again, that isn't W3C approved... but it works...

node.innerHTML="new value";