I\'d like to update element\'s text dynamically:
**text to change**
text t
For the specific case you mentioned:
**text to change**
text that should not change
text that should not change
... this is very easy:
var div = document.getElementById("foo");
div.firstChild.data = "New text";
You don't state how you want to generalize this. If, say, you want to change the text of the first text node within the var child = div.firstChild;
while (child) {
if (child.nodeType == 3) {
child.data = "New text";
break;
}
child = child.nextSibling;
}