Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
Source by attacomsian.com #
 
PREVIOUS NEXT
Tagged: #appending #element #element #javascript
ADD COMMENT
Topic
Name
3+5 =