Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

The Document Object Model (DOM) | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 8 of 55

·javascript

The Document Object Model (DOM)

12 mins

Course progress15%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `querySelector` returns the *first* matching element; `querySelectorAll` returns a **NodeList**.
  • The DOM is **live** – changes appear immediately in the rendered page.
  • Prefer **`textContent`** over `innerHTML` when you only need to set plain text.

The DOM is a tree‑like representation of the HTML document.

  • document – entry point.
  • document.querySelector() / querySelectorAll() – CSS selector based retrieval.
  • document.getElementById(), getElementsByClassName(), getElementsByTagName() – legacy methods.

Node types: Element, Text, Comment, DocumentFragment.

Example: Selecting and modifying an element

const title = document.querySelector('h1');
title.textContent = 'Updated Title';
title.style.color = '#0066cc';
Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonScope, Closures & the Execution ContextContinue to lesson 9Manipulating the DOM – Creation, Insertion & RemovalBack to JavaScript Course curriculum