Answers for "javascript dom nod append"

3

create and append element in javascript

//create and append element
 var node = document.createElement("LI");                 // Create a <li> node

 var textnode = document.createTextNode("Water");         // Create a text node

 node.appendChild(textnode);                              // Append the text to <li>

 document.getElementById("myList").appendChild(node);
Posted by: Guest on December-30-2020
1

document.append

/*adds  a element directly to the document without needing a parent or 
container*/

let addTag = document.createElement("html")
document.append(addTag)

//or

let addTag2 = document.createElement("p")
document.body.append(addTag2)
Posted by: Guest on January-17-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language