So I've been slowly replacing a lot of my normal jQuery code with native javascript, and I happened upon the document.createTextNode()
and related MDN documentation. After reading I'm somewhat confused what a text node is.
I understand it can be used to put text inside div
's, but I'm sure there's a bit more to it than just "use it to put words inside elements". Looking at this, it appears a text node can also refer to the text of attributes as well.
Can anyone provide a bit more of a definition of what a text node is and what it's used for? Are there practical uses for this other than basic stuff like this?
var div = document.createElement('div');
var text = document.createTextNode('Y HALO THAR');
div.appendChild(text);