JS-151-API
  • JavaScript Library
  • 02-DOM-Manipulation
    • Overview
    • DOM Explained
    • Example Setup
    • Selecting Elements
    • Events
    • Complete Example
  • 03-API Fundamentals
    • 0-Getting Started
      • Welcome
    • 1-Intro-To-APIs
      • Intro
      • Client
      • Requests
      • JSON
      • API Endpoints
      • Server
      • Response
      • Statelessness
      • REST
    • 2-Asynchronous-Programming
      • Intro
      • Callbacks
      • Promises
      • Promises Continued
      • Chaining Promises
    • 3-Fetch
      • Fetch Intro
      • Star Wars
        • Star Wars API
        • Star Wars Setup
        • Star Wars JS
      • Random Photo
        • Unsplash
        • Unsplash Setup
        • Unsplash JS
    • 4-Apps
      • 01-New York Times
        • 00-App Intro
        • 01-HTML/CSS/API Key
        • 02-Variables
        • 03-Event Listeners
        • 04-fetchResults
          • 01-fetchResults()
          • 02-preventDefault()
          • 03-fetch() method
          • 04-Dates
        • 05-displayResults
          • 01-Logging JSON
          • 02-Working with JSON
          • 03-Link Display
          • 04-Results Navigation
          • 05-Results Update
          • 06-Keywords
          • 07-Images
        • 06-Pagination
          • 01-Pagination Intro
          • 02-Pagination Functions
        • 07-Next Steps
      • 02-YouTube
        • html
        • youtube.css
        • youtube.js
      • 03-GoogleMaps
        • Setup
        • HTML and CSS files
        • API Key
        • JS Setup
        • Adding Your Location
        • Listeners
        • Custom Options
Powered by GitBook
On this page
  1. 02-DOM-Manipulation

DOM Explained

You may have noticed there is one really big thing missing in your coding education so far... we've learned about loops, arrays, objects, variables, and conditionals... we've built a basic HTML and CSS page... and we've written JavaScript that runs in the console... but how do we make it happen on command? What if we want an HTML button to control when a JavaScript function runs? What if we want JavaScript to change some CSS styling?

DOM stands for Document Object Model, and it is what allows our JavaScript to interact with the HTML and CSS of our page.

If you want to get technical, the abbreviation "DOM" gives us a hint of what it actually is, on the most basic level. It's an Object Model - it's the entire HTML document (or "page") represented as an object. If you can remember objects, objects have properties and methods (functions) and so does the DOM! Since the DOM is the entire HTML document represented as an object, the properties and methods deal with that HTML document.

The overall DOM consists of the entire page, including all of the paragraph tags, input fields, images, div tags, etc. on the page. The properties of those tags are part of the properties of the DOM. Want to change the style of a paragraph tag? The "style" is a property of that paragraph tag, which is part of the DOM. The DOM also gives us "methods" (remember, "functions" are called "methods" when they are part of an object) to manipulate things too!

Enough conceptual talk, it's a difficult concept to grasp at first, especially when you haven't seen it in action! Soooo..... Let's look at a few examples!

PreviousOverviewNextExample Setup

Last updated 7 years ago