Neuer Blabla

— 1 minute read

There are a couple of important things to note here. First, text nodes do not have an ID attribute like element nodes can. So they cannot be accessed directly using methods like document.getElementById() or document.getElementsByTagName().

Instead, the code references the text using the parent node, in this case it’s the paragraph element with the ID “sample1”. This element node has one child node, the text node we want to update. You can see this in the diagram below.