Chapter 6: The Document Object Model

The Document Object Model (DOM) allows you to access elements of a web page and enable interaction with the page by adding and removing elements, changing the order, content and attributes of elements, and even altering how they are styled.

In this chapter, we’ll cover the following topics:

  • Introduction to the DOM

  • Getting elements ―getElementById, getElementsByClassName, getElementsByTagName, querySelector and querySelectorAll

  • Navigating the DOM

  • Getting and setting an element’s attributes

  • Updating the DOM by creating dynamic markup

  • Changing the CSS of an element

  • Our project ― we'll dynamically insert each question into the HTML

The Document Object Model

What is the DOM?

The Document Object Model, ...

Get JavaScript: Novice to Ninja, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.