//create and append elementvar node = document.createElement("LI"); // Create a <li> nodevar textnode = document.createTextNode("Water"); // Create a text node
node.appendChild(textnode); // Append the text to <li>document.getElementById("myList").appendChild(node);
let div = document.createElement("div")
console.log(div.textContent) // "Some text"
In this page (written and validated by A. Gawali) you learned about
. What's Next? If you are interested in completing HTML tutorial, we encourage you simply to start here: HTML Tutorial.
Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: firstname.lastname@example.org.