Sikau

JavaScript · Day 44 · about 25 min

Changing the page

Text, classes and styles.

From reading to writing

Finding elements is half the fun. Now let's change them: new text, new styles, new classes. This is how scores update, buttons light up and messages appear.

Changing text and style

const score = document.querySelector("#score");
score.textContent = "Score: 10";

const title = document.querySelector("h1");
title.style.color = "crimson";
title.style.fontSize = "40px";

The rest of this lesson

  • Classes are betterexplain
  • textContent, classes and attributesexplain
  • Predictpredict
  • Togglingpredict
  • 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