Skip to content

Lesson 02 · The DOM

The DOM: Creating, Updating & Removing Content

Elements from scratch: creating nodes and configuring them, placing them precisely with append and friends, rendering lists from data, removing and replacing nodes, and batching inserts without danger.

Prerequisites: The DOM: Selecting & Traversing the Live Document

Learning objectives
By the end of this lesson, you will be able to:
  • Create elements and set their text, classes and attributes
  • Place nodes exactly with append, prepend, before and after
  • Render a list from an array of data with a loop or map
  • Remove and replace nodes without touching the rest of the tree
  • Batch many inserts through a DocumentFragment and clone shapes with cloneNode