Skip to content

Day 3: Creating & Removing Elements

Dynamically instantiate new DOM nodes and remove existing elements from the page.

const newCard = document.createElement('div');
newCard.classList.add('card');
newCard.textContent = 'Dynamic Card Content';
const container = document.querySelector('.container');
container.append(newCard); // attaches to page
// Removing
// newCard.remove();
  1. Build a list item generator that appends a new <li> every time a button is clicked.