Sikau

JavaScript Applications · Day 12 · about 30 min

Creating elements

Building lists from arrays.

Pages built by code

Your social feed isn't written by hand in HTML — code builds each post from data. Today you'll create brand-new elements and add them to the page, often from an array.

createElement and append

const list = document.querySelector("#list");

const item = document.createElement("li");
item.textContent = "Pani puri";
list.append(item);

The rest of this lesson

  • From an arrayexplain
  • Building richer elementsexplain
  • Predictpredict
  • Add an item to a listorder
  • Your turnwrite code
  • Challengechallenge
  • Badge quizquiz
  • What you learnedrecap