Is there anyway to assign an id to a textNode and then retrieve that text node via that id? I've tried several different ways and keep getting errors saying cannot get property of null.
My code looks something like this...
var myDiv = document.createdElement('div');
myDiv.id = "textContainer";
var textNode = document.createdTextNode("some text");
textNode.id = "descriptionText";
myDiv.appendChild(textNode);
Works fine to this point; it displays on the page. Later I try to modify that text node and that's where I'm getting the errors.
var tempNode = document.getElementById(descriptionText);
descriptionText.value = "new text";
And it's a no go. I've tried variates like naming by text node with tagName, data, etc., and I'm getting the same error. So, is it not possible to name and retrieve a text node? And the next best solution to create new text nodes and replace the old text node?