Sikau

JavaScript · Day 47 · 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

Continue this lesson free — run real code in your browser

Continue with Google

See all 68 lessons of JavaScript