Learn JavaScript

Lesson 2 of 9 · The DOM and Events: JavaScript Touches the Page

Module 14 · The DOM and Events: JavaScript Touches the Page

Every DOM Tool, One by One, With What It Returns

Free with an accountReading

Kenji builds a small page for his uncle's tea stall. It lists the teas with their prices, has a search box, a basket counter, and a button to mark a tea as sold out. Each part needs a different tool. One finds many elements at once, one makes new ones, one listens for typing, one keeps a click from reaching the parent.

Checking what this lesson needs for you…

What is inside Every DOM Tool, One by One, With What It Returns

  1. querySelector and querySelectorAll
  2. getElementById and getElementsByClassName
  3. textContent
  4. innerHTML, and the injection risk
  5. createElement, append and remove
  6. classList
  7. style, and why a class is better
  8. Attributes and data attributes
  9. The event object
  10. Bubbling, capturing and stopPropagation
  11. Event delegation
  12. preventDefault
  13. The common events
  14. Removing a listener