Locked lesson.
About this lesson
Finding, changing, adding, and deleting elements.
Exercise files
Download this lesson’s related exercise files.
Dom Document Objects.docx59 KB Dom Document Objects - Solution.docx
59.1 KB
Quick reference
Dom Document Objects
DOM Document Objects allow us to manipulate most aspects of an HTML page.
When to use
Anytime you want to manipulate HTML, you'll likely focus on document objects.
Instructions
There are several methods that allow us to grab DOM objects:
getElementById();
getElementsByTagName();
getElementsByClassName();
Once we grab those objects, we can manipulate them with:
.innerHTML;
.attribute;
.setAttribute(attribute, value);
.style.property;
We can create an HTML element:
document.createElement(element);
We can remove an HTML element:
document.removeChild(element);
We can append an HTML element:
document.appendChild(element);
We can replace an HTML element:
document.replaceChild(element);
Hints & tips
- We can grab DOM objects by ID, TagName, and ClassName
- We can manipulate DOM Objects with innerHTML, attribute, setAttribute, and style.property
- We'll look at how to use each of these things later
Lesson notes are only available for subscribers.