DOM Objects Worksheet

Question 1

In order to use the document.getElementById() method to 'get a handle' on an element, what attribute must that element have?

To use document.getElementById(), the element just needs to have an id attribute. The id is like a unique name for that element, so when you use document.getElementById("someId"), it knows exactly which element you're talking about.

Question 2

When you invoke document.getElementById(), you must pass in a string parameter. What does the parameter represent?

The parameter you pass into document.getElementById() is a string that represents the ID of the element you want to access. It tells JavaScript which specific element on the page to "grab" or work with.

Question 3

What does the document.getElementById() method return?

document.getElementById() gives you the actual element from the page that matches the ID you provided. So, you can then change things about it, like its text or style. If there’s no element with that ID, it just gives back null

Question 4

What object is at the top of the DOM? In other words, what DOM object contains all other DOM objects?

The document object is at the top of the DOM. It represents the whole web page and contains all other elements and objects in the DOM.


Coding Problems

You'll use the following elements to complete the coding problems:

Problem 1


Problem 2
A bald eagle

Problem 3
This is myDiv


Problem 4

Sign Up Form

Complete this form to sign up