Answers for "appending an element to another element javascript"

0

appending an element to another element javascript

const drinks = document.querySelector('#drinks');

// Create a <li> element
const elem = document.createElement("li");

// Create a new text node
const text = document.createTextNode("Tea");

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

// Finally, append <li> to <ul> node
drinks.appendChild(elem);
Posted by: Guest on March-12-2022

Code answers related to "appending an element to another element javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language