document.createElement

  • document.createElement("div") - Creates a DOM div
  • Add text / classes / etc with normal DOM properties
  • Starts out unattached to the page. Need to tell JS where to put it
  • element.appendChild(child) - Attach the child as the last child of another element
  • element.insertAdjacentElement('afterend', sibling) - Attach the sibling element next to the element

7 / 17