Working with the Text Node and Changing Content

For Text Node there is also no traveling inside a text node, because it can't have any children.

With the JavaScript method innerHTML, we can change or modify the content.

    <div id="target-area">
        <p>This is our text.</p>

In this example, we target the text node and change it to "hello world".

// targeting the text node
document.getElementById("target-area"). innerHTML ;

// changing the content in the text node - you can jump straight to this.
document.getElementById("target-area"). innerHTML = "<p>hello world</p>";
Related Tutorial
Follow Us #