1var div = document.getElementById('myElementID');
2div.innerHTML += "Here is some more data appended";
1//create and append element
2 var node = document.createElement("LI"); // Create a <li> node
3
4 var textnode = document.createTextNode("Water"); // Create a text node
5
6 node.appendChild(textnode); // Append the text to <li>
7
8 document.getElementById("myList").appendChild(node);
1let parent = document.createElement("div")
2parent.append("Some text")
3
4console.log(parent.textContent) // "Some text"
1
2
3
4
5 let app = document.querySelector('#app');
6app.append('append() Text Demo');
7
8console.log(app.textContent);
1var element = document.getElementById("div1");
2element.insertBefore(para, element.firstChild);
1const parent = document.createElement('div');
2const child = document.createElement('p');
3// Appending Node Objects
4parent.append(child) // Works fine
5parent.appendChild(child) // Works fine
6// Appending DOMStrings
7parent.append('Hello world') // Works fine
8parent.appendChild('Hello world') // Throws error
9