🎯 Learning Objectives

By the end of this lecture, students will be able to:

#️⃣ 1. What is the DOM (Document Object Model)?

When a browser loads a webpage:

  1. It reads the HTML file.
  2. It converts each HTML tag into a JavaScript object.
  3. It organizes these objects in a tree-like structure called the DOM Tree.

🌳 DOM Tree Visualization

For this HTML:

<body>
  <h1>Welcome</h1>
  <p>Hello world</p>
  <button>Click me</button>
</body>

The DOM becomes:

document
│
└── body
     ├── h1
     ├── p
     └── button